home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / gridex / frmmain.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-01-03  |  38.6 KB  |  1,064 lines

  1. VERSION 5.00
  2. Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.2#0"; "COMCTL32.OCX"
  3. Object = "{BA7155BB-813E-11D1-B8F4-0080ADA85B53}#1.0#0"; "JSGridEX.ocx"
  4. Begin VB.Form frmMain 
  5.    Caption         =   "The Janus GridEX - Advanced Sample - (Northwind Traders)"
  6.    ClientHeight    =   6045
  7.    ClientLeft      =   330
  8.    ClientTop       =   1860
  9.    ClientWidth     =   8595
  10.    Icon            =   "frmMain.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    LockControls    =   -1  'True
  13.    ScaleHeight     =   6045
  14.    ScaleWidth      =   8595
  15.    StartUpPosition =   2  'CenterScreen
  16.    Begin ComctlLib.Toolbar tlbMain 
  17.       Align           =   1  'Align Top
  18.       Height          =   420
  19.       Left            =   0
  20.       TabIndex        =   3
  21.       Top             =   0
  22.       Width           =   8595
  23.       _ExtentX        =   15161
  24.       _ExtentY        =   741
  25.       ButtonWidth     =   609
  26.       ButtonHeight    =   582
  27.       AllowCustomize  =   0   'False
  28.       Wrappable       =   0   'False
  29.       Appearance      =   1
  30.       ImageList       =   "iml16"
  31.       _Version        =   327682
  32.       BeginProperty Buttons {0713E452-850A-101B-AFC0-4210102A8DA7} 
  33.          NumButtons      =   15
  34.          BeginProperty Button1 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  35.             Key             =   ""
  36.             Object.Tag             =   ""
  37.             Style           =   3
  38.             MixedState      =   -1  'True
  39.          EndProperty
  40.          BeginProperty Button2 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  41.             Key             =   ""
  42.             Object.Tag             =   ""
  43.             Style           =   4
  44.             Object.Width           =   1200
  45.             MixedState      =   -1  'True
  46.          EndProperty
  47.          BeginProperty Button3 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  48.             Key             =   "Edit"
  49.             Object.Tag             =   ""
  50.             ImageIndex      =   12
  51.          EndProperty
  52.          BeginProperty Button4 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  53.             Key             =   ""
  54.             Object.Tag             =   ""
  55.             Style           =   3
  56.             MixedState      =   -1  'True
  57.          EndProperty
  58.          BeginProperty Button5 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  59.             Key             =   "Summary"
  60.             Object.ToolTipText     =   "View Summary..."
  61.             Object.Tag             =   ""
  62.             ImageIndex      =   11
  63.          EndProperty
  64.          BeginProperty Button6 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  65.             Key             =   "Group"
  66.             Object.ToolTipText     =   "Group by..."
  67.             Object.Tag             =   ""
  68.             ImageIndex      =   7
  69.          EndProperty
  70.          BeginProperty Button7 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  71.             Key             =   "Sort"
  72.             Object.ToolTipText     =   "Sort..."
  73.             Object.Tag             =   ""
  74.             ImageIndex      =   8
  75.          EndProperty
  76.          BeginProperty Button8 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  77.             Key             =   ""
  78.             Object.Tag             =   ""
  79.             Style           =   3
  80.             MixedState      =   -1  'True
  81.          EndProperty
  82.          BeginProperty Button9 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  83.             Key             =   "ShowGroupByBox"
  84.             Object.ToolTipText     =   "Group By Box"
  85.             Object.Tag             =   ""
  86.             ImageIndex      =   9
  87.             Style           =   1
  88.             Value           =   1
  89.          EndProperty
  90.          BeginProperty Button10 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  91.             Key             =   "AllowAddNew"
  92.             Object.ToolTipText     =   "Show Allow Add New Row"
  93.             Object.Tag             =   ""
  94.             ImageIndex      =   10
  95.             Style           =   1
  96.             Value           =   1
  97.          EndProperty
  98.          BeginProperty Button11 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  99.             Key             =   ""
  100.             Object.Tag             =   ""
  101.             Style           =   4
  102.             Object.Width           =   2500
  103.             MixedState      =   -1  'True
  104.          EndProperty
  105.          BeginProperty Button12 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  106.             Key             =   "MoveFirst"
  107.             Object.ToolTipText     =   "Move first visible record"
  108.             Object.Tag             =   ""
  109.             ImageIndex      =   13
  110.          EndProperty
  111.          BeginProperty Button13 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  112.             Key             =   "MovePrevious"
  113.             Object.ToolTipText     =   "Move previous visible record"
  114.             Object.Tag             =   ""
  115.             ImageIndex      =   14
  116.          EndProperty
  117.          BeginProperty Button14 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  118.             Key             =   "MoveNext"
  119.             Object.ToolTipText     =   "Move next visible record"
  120.             Object.Tag             =   ""
  121.             ImageIndex      =   15
  122.          EndProperty
  123.          BeginProperty Button15 {0713F354-850A-101B-AFC0-4210102A8DA7} 
  124.             Key             =   "MoveLast"
  125.             Object.ToolTipText     =   "Move last visible record"
  126.             Object.Tag             =   ""
  127.             ImageIndex      =   16
  128.          EndProperty
  129.       EndProperty
  130.       Begin VB.CommandButton cmdNewRecord 
  131.          Appearance      =   0  'Flat
  132.          Caption         =   "New Record"
  133.          BeginProperty Font 
  134.             Name            =   "Tahoma"
  135.             Size            =   8.25
  136.             Charset         =   0
  137.             Weight          =   400
  138.             Underline       =   0   'False
  139.             Italic          =   0   'False
  140.             Strikethrough   =   0   'False
  141.          EndProperty
  142.          Height          =   330
  143.          Left            =   120
  144.          TabIndex        =   7
  145.          TabStop         =   0   'False
  146.          Top             =   30
  147.          Width           =   1200
  148.       End
  149.       Begin VB.ComboBox cboStyle 
  150.          Appearance      =   0  'Flat
  151.          Height          =   315
  152.          Left            =   3720
  153.          Style           =   2  'Dropdown List
  154.          TabIndex        =   4
  155.          Top             =   45
  156.          Width           =   2325
  157.       End
  158.    End
  159.    Begin ComctlLib.TreeView tvwCatalog 
  160.       Height          =   4905
  161.       Left            =   90
  162.       TabIndex        =   0
  163.       Top             =   1080
  164.       Width           =   2295
  165.       _ExtentX        =   4048
  166.       _ExtentY        =   8652
  167.       _Version        =   327682
  168.       HideSelection   =   0   'False
  169.       Indentation     =   265
  170.       LabelEdit       =   1
  171.       LineStyle       =   1
  172.       Style           =   7
  173.       ImageList       =   "iml16"
  174.       Appearance      =   1
  175.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  176.          Name            =   "Tahoma"
  177.          Size            =   8.25
  178.          Charset         =   0
  179.          Weight          =   400
  180.          Underline       =   0   'False
  181.          Italic          =   0   'False
  182.          Strikethrough   =   0   'False
  183.       EndProperty
  184.    End
  185.    Begin JSGridEX.GridEX jGrid 
  186.       Height          =   4890
  187.       Left            =   2415
  188.       TabIndex        =   5
  189.       Top             =   1080
  190.       Visible         =   0   'False
  191.       Width           =   6150
  192.       _ExtentX        =   10848
  193.       _ExtentY        =   8625
  194.       MethodHoldFields=   -1  'True
  195.       AllowDelete     =   -1  'True
  196.       MaskColor       =   16711935
  197.       ImageCount      =   5
  198.       ImagePicture1   =   "frmMain.frx":030A
  199.       ImagePicture2   =   "frmMain.frx":0624
  200.       ImagePicture3   =   "frmMain.frx":093E
  201.       ImagePicture4   =   "frmMain.frx":0C58
  202.       ImagePicture5   =   "frmMain.frx":0F72
  203.       ColumnCount     =   2
  204.       CardCaption1    =   -1  'True
  205.       ColEditType1    =   3
  206.       AllowAddNew     =   -1  'True
  207.       ColumnHeaderHeight=   330
  208.    End
  209.    Begin VB.PictureBox picMain 
  210.       Height          =   4890
  211.       Left            =   2415
  212.       ScaleHeight     =   322
  213.       ScaleMode       =   3  'Pixel
  214.       ScaleWidth      =   406
  215.       TabIndex        =   6
  216.       Top             =   1080
  217.       Width           =   6150
  218.       Begin VB.Image imglogo 
  219.          Height          =   1815
  220.          Left            =   4065
  221.          Picture         =   "frmMain.frx":128C
  222.          Top             =   150
  223.          Width           =   1935
  224.       End
  225.    End
  226.    Begin ComctlLib.ImageList iml16 
  227.       Left            =   7590
  228.       Top             =   480
  229.       _ExtentX        =   1005
  230.       _ExtentY        =   1005
  231.       BackColor       =   -2147483643
  232.       ImageWidth      =   16
  233.       ImageHeight     =   16
  234.       MaskColor       =   12632256
  235.       _Version        =   327682
  236.       BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7} 
  237.          NumListImages   =   16
  238.          BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  239.             Picture         =   "frmMain.frx":2557
  240.             Key             =   ""
  241.          EndProperty
  242.          BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  243.             Picture         =   "frmMain.frx":2871
  244.             Key             =   ""
  245.          EndProperty
  246.          BeginProperty ListImage3 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  247.             Picture         =   "frmMain.frx":2B8B
  248.             Key             =   ""
  249.          EndProperty
  250.          BeginProperty ListImage4 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  251.             Picture         =   "frmMain.frx":2EA5
  252.             Key             =   ""
  253.          EndProperty
  254.          BeginProperty ListImage5 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  255.             Picture         =   "frmMain.frx":31BF
  256.             Key             =   ""
  257.          EndProperty
  258.          BeginProperty ListImage6 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  259.             Picture         =   "frmMain.frx":34D9
  260.             Key             =   ""
  261.          EndProperty
  262.          BeginProperty ListImage7 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  263.             Picture         =   "frmMain.frx":37F3
  264.             Key             =   "Group"
  265.             Object.Tag             =   "Group"
  266.          EndProperty
  267.          BeginProperty ListImage8 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  268.             Picture         =   "frmMain.frx":3B0D
  269.             Key             =   "Sort"
  270.          EndProperty
  271.          BeginProperty ListImage9 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  272.             Picture         =   "frmMain.frx":3E27
  273.             Key             =   ""
  274.          EndProperty
  275.          BeginProperty ListImage10 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  276.             Picture         =   "frmMain.frx":4141
  277.             Key             =   ""
  278.          EndProperty
  279.          BeginProperty ListImage11 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  280.             Picture         =   "frmMain.frx":445B
  281.             Key             =   ""
  282.          EndProperty
  283.          BeginProperty ListImage12 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  284.             Picture         =   "frmMain.frx":4775
  285.             Key             =   ""
  286.          EndProperty
  287.          BeginProperty ListImage13 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  288.             Picture         =   "frmMain.frx":4A8F
  289.             Key             =   ""
  290.          EndProperty
  291.          BeginProperty ListImage14 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  292.             Picture         =   "frmMain.frx":4DA9
  293.             Key             =   ""
  294.          EndProperty
  295.          BeginProperty ListImage15 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  296.             Picture         =   "frmMain.frx":50C3
  297.             Key             =   ""
  298.          EndProperty
  299.          BeginProperty ListImage16 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  300.             Picture         =   "frmMain.frx":53DD
  301.             Key             =   ""
  302.          EndProperty
  303.       EndProperty
  304.    End
  305.    Begin VB.Label lblfront 
  306.       AutoSize        =   -1  'True
  307.       BackColor       =   &H80000010&
  308.       BackStyle       =   0  'Transparent
  309.       Caption         =   "Northwind Traders"
  310.       BeginProperty Font 
  311.          Name            =   "Tahoma"
  312.          Size            =   18
  313.          Charset         =   0
  314.          Weight          =   400
  315.          Underline       =   0   'False
  316.          Italic          =   0   'False
  317.          Strikethrough   =   0   'False
  318.       EndProperty
  319.       ForeColor       =   &H80000005&
  320.       Height          =   435
  321.       Left            =   180
  322.       TabIndex        =   2
  323.       Top             =   495
  324.       Width           =   2970
  325.    End
  326.    Begin ComctlLib.ImageList iml32 
  327.       Left            =   8175
  328.       Top             =   480
  329.       _ExtentX        =   1005
  330.       _ExtentY        =   1005
  331.       BackColor       =   -2147483643
  332.       ImageWidth      =   32
  333.       ImageHeight     =   32
  334.       MaskColor       =   12632256
  335.       _Version        =   327682
  336.       BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7} 
  337.          NumListImages   =   6
  338.          BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  339.             Picture         =   "frmMain.frx":56F7
  340.             Key             =   ""
  341.          EndProperty
  342.          BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  343.             Picture         =   "frmMain.frx":5A11
  344.             Key             =   ""
  345.          EndProperty
  346.          BeginProperty ListImage3 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  347.             Picture         =   "frmMain.frx":5D2B
  348.             Key             =   ""
  349.          EndProperty
  350.          BeginProperty ListImage4 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  351.             Picture         =   "frmMain.frx":6045
  352.             Key             =   ""
  353.          EndProperty
  354.          BeginProperty ListImage5 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  355.             Picture         =   "frmMain.frx":635F
  356.             Key             =   ""
  357.          EndProperty
  358.          BeginProperty ListImage6 {0713E8C3-850A-101B-AFC0-4210102A8DA7} 
  359.             Picture         =   "frmMain.frx":6679
  360.             Key             =   ""
  361.          EndProperty
  362.       EndProperty
  363.    End
  364.    Begin VB.Image imgCat 
  365.       Height          =   480
  366.       Left            =   7035
  367.       Picture         =   "frmMain.frx":6993
  368.       Top             =   480
  369.       Width           =   480
  370.    End
  371.    Begin VB.Label lblback 
  372.       BackColor       =   &H80000010&
  373.       Height          =   555
  374.       Left            =   90
  375.       TabIndex        =   1
  376.       Top             =   450
  377.       Width           =   7530
  378.    End
  379.    Begin VB.Menu mnuFile 
  380.       Caption         =   "File"
  381.       Begin VB.Menu mnuExit 
  382.          Caption         =   "Exit"
  383.       End
  384.    End
  385.    Begin VB.Menu mnuView 
  386.       Caption         =   "View"
  387.       Begin VB.Menu mnuCurrentView 
  388.          Caption         =   "CurrentView"
  389.          Begin VB.Menu MnuViewStyle 
  390.             Caption         =   ""
  391.             Index           =   0
  392.          End
  393.       End
  394.       Begin VB.Menu mnuViewSep 
  395.          Caption         =   "-"
  396.       End
  397.       Begin VB.Menu mnushow 
  398.          Caption         =   "Show Fields..."
  399.       End
  400.       Begin VB.Menu mnusort 
  401.          Caption         =   "Sort..."
  402.       End
  403.       Begin VB.Menu mnugroup 
  404.          Caption         =   "Group By..."
  405.       End
  406.       Begin VB.Menu mnuformat 
  407.          Caption         =   "Format View..."
  408.       End
  409.       Begin VB.Menu mnuEXCol 
  410.          Caption         =   "Expand/Collapse Groups"
  411.          Begin VB.Menu mnucolall 
  412.             Caption         =   "Collapse All"
  413.          End
  414.          Begin VB.Menu mnuexpall 
  415.             Caption         =   "Expand All"
  416.          End
  417.       End
  418.       Begin VB.Menu mnuSum 
  419.          Caption         =   "View Summary..."
  420.       End
  421.       Begin VB.Menu mnusep1 
  422.          Caption         =   "-"
  423.       End
  424.       Begin VB.Menu mnugbBox 
  425.          Caption         =   "Group By Box"
  426.          Checked         =   -1  'True
  427.       End
  428.    End
  429.    Begin VB.Menu mnuHelp 
  430.       Caption         =   "Help"
  431.       Begin VB.Menu mnuAbout 
  432.          Caption         =   "About"
  433.       End
  434.    End
  435. Attribute VB_Name = "frmMain"
  436. Attribute VB_GlobalNameSpace = False
  437. Attribute VB_Creatable = False
  438. Attribute VB_PredeclaredId = True
  439. Attribute VB_Exposed = False
  440. Option Explicit
  441. Option Compare Text
  442. Dim m_CurrentView As Long
  443. Dim m_CatalogIndex As Long
  444. Dim m_db As Database
  445. Dim m_LastBaseIcon As Integer
  446. Dim mvarBookmark As Variant
  447. Dim mcolForms As New Collection
  448. Public Sub OnRecordUpdate(ByVal CatalogIndex As Integer, Bookmark As Variant)
  449.     If m_CatalogIndex = CatalogIndex Then
  450.         jGrid.Refresh
  451.         If IsNull(Bookmark) Then
  452.             jGrid.SearchNewRecords
  453.         Else
  454.             jGrid.MoveToBookmark Bookmark
  455.             jGrid.Update
  456.         End If
  457.     End If
  458. End Sub
  459. Private Sub cboStyle_Click()
  460. Dim rstViews As Recordset
  461. Dim rsViewDetails As Recordset
  462. Dim rsCatalogDetails As Recordset
  463. Dim col As Column
  464. Dim lngColumnId As Long
  465. Dim IsTableView As Boolean
  466.     If cboStyle.ListIndex = -1 Then Exit Sub
  467.     Screen.MousePointer = 11
  468.     jGrid.Visible = False
  469.     m_CurrentView = cboStyle.ItemData(cboStyle.ListIndex)
  470.     Set rstViews = m_db.OpenRecordset("Views", dbOpenTable)
  471.     Set rsViewDetails = m_db.OpenRecordset("ViewDetails", dbOpenTable)
  472.     rsViewDetails.Index = "PrimaryKey"
  473.     rstViews.Index = "PrimaryKey"
  474.     rstViews.Seek "=", m_CurrentView
  475.     If Not rstViews.NoMatch Then
  476.         With jGrid
  477.             .View = rstViews![GridView]
  478.             With .Font
  479.                 .Name = rstViews![FontName]
  480.                 .Size = rstViews![FontSize]
  481.                 .Bold = rstViews![FontBold]
  482.                 .Italic = rstViews![FontItalic]
  483.                 .Strikethrough = rstViews![FontStrikethru]
  484.                 .Underline = rstViews![FontUnderline]
  485.             End With
  486.             With .ColumnHeaderFont
  487.                 .Name = rstViews![HeaderFontName]
  488.                 .Size = rstViews![HeaderFontSize]
  489.                 .Bold = rstViews![HeaderFontBold]
  490.                 .Italic = rstViews![HeaderFontItalic]
  491.                 .Strikethrough = rstViews![HeaderFontStrikethru]
  492.                 .Underline = rstViews![HeaderFontUnderline]
  493.             End With
  494.             .ForeColorHeader = rstViews![HeaderFontColor]
  495.             .ForeColor = rstViews![FontColor]
  496.             .GridLines = rstViews![GridLines]
  497.             GroupByBoxVisible rstViews![ShowGroupByBox]
  498.             .AllowEdit = rstViews![AllowEdit]
  499.             AllowAddNew rstViews![AllowAddNew]
  500.             .CardWidth = rstViews![CardWith]
  501.             .CardCaptionPrefix = Format(rstViews![CardPrefix])
  502.             Set rsCatalogDetails = m_db.OpenRecordset("CatalogDetails", dbOpenTable)
  503.             rsCatalogDetails.Index = "CatalogIndex"
  504.             For Each col In .Columns
  505.                 rsCatalogDetails.Seek "=", m_CatalogIndex, col.Index
  506.                 If Not rsCatalogDetails.NoMatch Then
  507.                     lngColumnId = rsCatalogDetails![ColumnID]
  508.                 Else
  509.                     lngColumnId = 0
  510.                 End If
  511.                 rsViewDetails.Seek "=", m_CurrentView, lngColumnId
  512.                 If Not rsViewDetails.NoMatch Then
  513.                     With col
  514.                         .Visible = rsViewDetails![Visible]
  515.                         .TextAlignment = rsViewDetails![TextAlignment]
  516.                         .Width = rsViewDetails![Width]
  517.                         .ColPosition = rsViewDetails![Position]
  518.                     End With
  519.                 End If
  520.             Next
  521.             With .FmtConditions
  522.                 .Clear
  523.                 .ShowGroupConditionCount = rstViews![ShowGroupConditionCount]
  524.                 .ApplyGroupCondition = rstViews![ApplyGroupCondition]
  525.                 .GroupConditionCountTitle = Format(rstViews![GroupConditionCountTitle])
  526.             End With
  527.             'Load FormatConditions
  528.             Dim rsConditions As Recordset
  529.             Dim fmtCon As FmtCondition
  530.             Dim fmtStyle As FormatStyle
  531.             Set rsConditions = m_db.OpenRecordset("ViewFormatConditions", dbOpenTable)
  532.             rsConditions.Index = "ViewIndex"
  533.             rsConditions.Seek ">=", m_CurrentView
  534.             If Not rsConditions.NoMatch Then
  535.                 Do Until rsConditions.EOF
  536.                     If rsConditions![ViewId] <> m_CurrentView Then Exit Do
  537.                     If rsConditions![Index] = 0 Then
  538.                         Set fmtCon = .FmtConditions.GroupCondition
  539.                         fmtCon.ColIndex = rsConditions![ColIndex]
  540.                         fmtCon.Operator = rsConditions![Operator]
  541.                         fmtCon.Value1 = rsConditions![Value1]
  542.                         fmtCon.Value2 = rsConditions![Value2]
  543.                     Else
  544.                         Set fmtCon = .FmtConditions.Add(rsConditions![ColIndex], rsConditions![Operator], rsConditions![Value1], rsConditions![Value2])
  545.                     End If
  546.                     Set fmtStyle = fmtCon.FormatStyle
  547.                     With fmtStyle
  548.                         .FontBold = rsConditions![FontBold]
  549.                         .FontItalic = rsConditions![FontItalic]
  550.                         .FontStrikethru = rsConditions![FontStrikethru]
  551.                         .FontUnderline = rsConditions![FontUnderline]
  552.                         .ForeColor = rsConditions![ForeColor]
  553.                     End With
  554.                     rsConditions.MoveNext
  555.                 Loop
  556.             End If
  557.             'Load SortKeys in View
  558.             Dim rsSortKeys As Recordset
  559.             .SortKeys.Clear
  560.             Set rsSortKeys = m_db.OpenRecordset("ViewSortKeys", dbOpenTable)
  561.             rsSortKeys.Index = "PrimaryKey"
  562.             rsSortKeys.Seek ">=", m_CurrentView
  563.             If Not rsSortKeys.NoMatch Then
  564.                 Do Until rsSortKeys.EOF
  565.                     If rsSortKeys![ViewId] <> m_CurrentView Then Exit Do
  566.                     .SortKeys.Add rsSortKeys![ColIndex], rsSortKeys![SortOrder]
  567.                     rsSortKeys.MoveNext
  568.                 Loop
  569.             End If
  570.             'Load Groups in View
  571.             Dim rsGroups As Recordset
  572.             .Groups.Clear
  573.             Set rsGroups = m_db.OpenRecordset("ViewGroups", dbOpenTable)
  574.             
  575.             rsGroups.Index = "PrimaryKey"
  576.             rsGroups.Seek ">=", m_CurrentView
  577.             If Not rsGroups.NoMatch Then
  578.                 Do Until rsGroups.EOF
  579.                     If rsGroups![ViewId] <> m_CurrentView Then Exit Do
  580.                     .Groups.Add rsGroups![ColIndex], rsGroups![SortOrder]
  581.                     rsGroups.MoveNext
  582.                 Loop
  583.             End If
  584.         End With
  585.     End If
  586.     IsTableView = (jGrid.View = jgexTable)
  587.     tlbMain.Buttons("ShowGroupByBox").Enabled = IsTableView
  588.     tlbMain.Buttons("Group").Enabled = IsTableView
  589.     tlbMain.Buttons("AllowAddNew").Enabled = IsTableView
  590.     mnugbBox.Enabled = IsTableView
  591.     mnugroup.Visible = IsTableView
  592.     mnuEXCol.Visible = IsTableView
  593.     CheckGroups
  594.     CheckMnuViewStyle
  595.     Screen.MousePointer = 0
  596.     jGrid.Visible = True
  597.     jGrid.SetFocus
  598. End Sub
  599. Private Sub cmdNewRecord_Click()
  600.     ShowRecord True
  601. End Sub
  602. Private Sub Form_Load()
  603.     m_LastBaseIcon = jGrid.GridImages.Count
  604.     LoadCatalogSettings
  605.     SetCatalog
  606. End Sub
  607. Private Sub Form_Resize()
  608. On Error Resume Next
  609. Dim i As Long
  610.     i = ScaleWidth - 650
  611.     If i < lblfront.Left + lblfront.Width + 60 Then i = lblfront.Left + lblfront.Width + 60
  612.     imgCat.Move i, imgCat.Top, imgCat.Width, imgCat.Height
  613.     lblback.Move 30, lblback.Top, ScaleWidth - 60, lblback.Height
  614.     tvwCatalog.Move 30, lblback.Top + lblback.Height + 60, tvwCatalog.Width, ScaleHeight - tvwCatalog.Top - 60
  615.     i = tvwCatalog.Left + 60 + tvwCatalog.Width
  616.     jGrid.Move i, tvwCatalog.Top, ScaleWidth - i - 30, ScaleHeight - tvwCatalog.Top - 60
  617.     With jGrid
  618.         picMain.Move .Left, .Top, .Width, .Height
  619.     End With
  620.      
  621.      
  622. End Sub
  623. Private Sub Form_Unload(Cancel As Integer)
  624. Dim frm As Object
  625. On Error GoTo EH_Unload
  626.     For Each frm In mcolForms
  627.         Unload frm
  628.     Next
  629.     Exit Sub
  630. EH_Unload:
  631.     MsgBox Err.Description
  632. End Sub
  633. Private Sub jGrid_AfterGroupChange()
  634.     CheckGroups
  635. End Sub
  636. Private Sub jGrid_BeforeGroupChange(Group As JSGridEX.Group, ByVal ChangeOperation As jgexGroupChange, ByVal GroupPosition As Integer, Cancel As Boolean)
  637. Dim col As Column
  638. Dim rstCatDetails As Recordset
  639.     If ChangeOperation = jgexGroupInsert Then
  640.         Set col = jGrid.Columns(Group.ColIndex)
  641.         Set rstCatDetails = m_db.OpenRecordset("CatalogDetails", dbOpenTable)
  642.         rstCatDetails.Index = "CatalogIndex"
  643.         rstCatDetails.Seek "=", m_CatalogIndex, col.Index
  644.         If Not rstCatDetails.NoMatch Then
  645.             If Not rstCatDetails![AllowGroup] Then
  646.                 MsgBox "You can not group items by this field.", vbInformation, "Advanced Sample"
  647.                 Cancel = True
  648.             End If
  649.         End If
  650.     End If
  651. End Sub
  652. Private Sub jGrid_ColumnHeaderClick(Column As JSGridEX.Column)
  653. Dim rstCatDetails As Recordset
  654. Dim grTemp As JSGridEX.Group
  655.     If Column.IsGrouped Then
  656.         For Each grTemp In jGrid.Groups
  657.             If grTemp.ColIndex = Column.Index Then
  658.                 jGrid_GroupByBoxHeaderClick grTemp
  659.             End If
  660.         Next
  661.     Else
  662.         If Column.SortOrder = 0 Then
  663.             Set rstCatDetails = m_db.OpenRecordset("CatalogDetails", dbOpenTable)
  664.             rstCatDetails.Index = "CatalogIndex"
  665.             rstCatDetails.Seek "=", m_CatalogIndex, Column.Index
  666.             If Not rstCatDetails.NoMatch Then
  667.                 If Not rstCatDetails![AllowSort] Then
  668.                     Exit Sub
  669.                 End If
  670.             End If
  671.             jGrid.SortKeys.Clear
  672.             jGrid.SortKeys.Add Column.Index, 1
  673.         Else
  674.             If Column.SortOrder = 1 Then
  675.                 jGrid.SortKeys.Clear
  676.                 jGrid.SortKeys.Add Column.Index, -1
  677.             Else
  678.                 jGrid.SortKeys.Clear
  679.                 jGrid.SortKeys.Add Column.Index, 1
  680.             End If
  681.         End If
  682.     End If
  683. End Sub
  684. Private Sub jGrid_DblClick()
  685.     ShowRecord
  686. End Sub
  687. Private Sub jGrid_GroupByBoxHeaderClick(Group As JSGridEX.Group)
  688.     Screen.MousePointer = 11
  689.     Group.SortOrder = -Group.SortOrder
  690.     jGrid.RefreshGroups
  691.     Screen.MousePointer = 0
  692. End Sub
  693. Private Sub lblback_DblClick()
  694. Static Collapsed As Boolean
  695.     If Collapsed Then
  696.         jGrid.ExpandAll
  697.     Else
  698.         jGrid.CollapseAll
  699.     End If
  700.     Collapsed = Not Collapsed
  701. End Sub
  702. Private Sub mnuAbout_Click()
  703.     frmAbout.Show 1
  704. End Sub
  705. Private Sub mnucolall_Click()
  706.     jGrid.CollapseAll
  707. End Sub
  708. Private Sub mnuExit_Click()
  709.     Unload Me
  710. End Sub
  711. Private Sub mnuexpall_Click()
  712.     jGrid.ExpandAll
  713. End Sub
  714. Private Sub mnuformat_Click()
  715.     If Not jGrid.Visible Then Exit Sub
  716.     If jGrid.View = jgexTable Then
  717.         frmTableview.FormatGrid jGrid
  718.     Else
  719.         frmCardView.FormatGrid jGrid
  720.     End If
  721. End Sub
  722. Private Sub mnugbBox_Click()
  723.     mnugbBox.Checked = Not mnugbBox.Checked
  724.     GroupByBoxVisible mnugbBox.Checked
  725. End Sub
  726. Private Sub mnugroup_Click()
  727.     frmGroupBy.GroupGrid jGrid
  728.     CheckGroups
  729. End Sub
  730. Private Sub mnushow_Click()
  731.     If Not jGrid.Visible Then Exit Sub
  732.     frmShowfields.ShowFields jGrid
  733. End Sub
  734. Private Sub mnusort_Click()
  735.     If Not jGrid.Visible Then Exit Sub
  736.     frmSort.SortGrid jGrid
  737. End Sub
  738. Private Sub mnuSum_Click()
  739.     frmSummary.ShowSummary jGrid
  740. End Sub
  741. Private Sub MnuViewStyle_Click(Index As Integer)
  742.     cboStyle.ListIndex = Index
  743. End Sub
  744. Private Sub tlbMain_ButtonClick(ByVal Button As ComctlLib.Button)
  745.     Select Case Button.Key
  746.         Case "Edit"
  747.             ShowRecord
  748.         Case "Group"
  749.             If Not jGrid.Visible Then Exit Sub
  750.             frmGroupBy.GroupGrid jGrid
  751.         Case "Sort"
  752.             If Not jGrid.Visible Then Exit Sub
  753.             frmSort.SortGrid jGrid
  754.         Case "ShowGroupByBox"
  755.             jGrid.GroupByBoxVisible = (Button.Value = tbrPressed)
  756.             mnugbBox.Checked = (Button.Value = tbrPressed)
  757.         Case "AllowAddNew"
  758.             jGrid.AllowAddNew = (Button.Value = tbrPressed)
  759.         Case "Summary"
  760.             frmSummary.ShowSummary jGrid
  761.         Case "MoveFirst"
  762.             jGrid.MoveFirst
  763.             jGrid.SetFocus
  764.         Case "MoveLast"
  765.             jGrid.MoveLast
  766.             jGrid.SetFocus
  767.         Case "MovePrevious"
  768.             jGrid.MovePrevious
  769.             jGrid.SetFocus
  770.         Case "MoveNext"
  771.             jGrid.MoveNext
  772.             jGrid.SetFocus
  773.     End Select
  774. End Sub
  775. Private Sub tvwCatalog_Click()
  776.     tvwCatalog_NodeClick tvwCatalog.SelectedItem
  777. End Sub
  778. Private Sub LoadCatalogSettings()
  779. Dim rstCatalogs As Recordset
  780. Dim nod As Node
  781. Dim lngParentIndex As Long
  782. Dim i As Integer
  783. Dim dbName As String
  784.     dbName = App.Path & "\NWind.mdb"
  785.     jGrid.DatabaseName = dbName
  786.     Set m_db = OpenDatabase(dbName)
  787.     Set rstCatalogs = m_db.OpenRecordset("Catalogs", dbOpenTable)
  788.     m_CatalogIndex = -1
  789.     Set nod = tvwCatalog.Nodes.Add(, , , "Northwind Traders", 1)
  790.     nod.Expanded = True
  791.     nod.Tag = 0
  792.     lngParentIndex = nod.Index
  793.     Do Until rstCatalogs.EOF
  794.         Set nod = tvwCatalog.Nodes.Add(lngParentIndex, tvwChild, , rstCatalogs![Name], CInt(rstCatalogs![IconIndex]))
  795.         nod.Tag = rstCatalogs![CatalogId]
  796.         rstCatalogs.MoveNext
  797.     Loop
  798.     tvwCatalog.Nodes(lngParentIndex).Selected = True
  799. End Sub
  800. Private Sub SetCatalog()
  801. Dim Node As Node
  802. Dim i As Integer
  803. Dim c As JSGridEX.Column
  804.     Set Node = tvwCatalog.SelectedItem
  805.     m_CatalogIndex = CLng(Node.Tag)
  806.     lblfront.Caption = Node.Text
  807.     jGrid.Visible = False
  808.     For i = jGrid.GridImages.Count To m_LastBaseIcon + 1 Step -1
  809.         jGrid.GridImages.Remove i
  810.     Next
  811.     If m_CatalogIndex = 0 Then
  812.         mnuView.Enabled = False
  813.         EnableButtons False
  814.         picMain.Visible = True
  815.         cboStyle.Clear
  816.         cboStyle.Enabled = False
  817.         jGrid.Visible = False
  818.     Else
  819.         mnuView.Enabled = True
  820.         EnableButtons True
  821.         picMain.Visible = False
  822.         LoadColumns
  823.         LoadCatalogFromRecordset
  824.         cboStyle.Enabled = True
  825.         jGrid.Visible = True
  826.         jGrid.Row = 1
  827.     End If
  828. End Sub
  829. Private Sub GroupByBoxVisible(ByVal Value As Boolean)
  830. Dim b As ComctlLib.Button
  831.     Set b = tlbMain.Buttons("ShowGroupByBox")
  832.     If (b.Value = tbrPressed) = Value Then Exit Sub
  833.     If Value Then
  834.         b.Value = tbrPressed
  835.     Else
  836.         b.Value = tbrUnpressed
  837.     End If
  838.     tlbMain_ButtonClick b
  839. End Sub
  840. Public Sub AllowAddNew(ByVal Value As Boolean)
  841. Dim b As ComctlLib.Button
  842.     Set b = tlbMain.Buttons("AllowAddNew")
  843.     If (b.Value = tbrPressed) = Value Then Exit Sub
  844.     If Value Then
  845.         b.Value = tbrPressed
  846.     Else
  847.         b.Value = tbrUnpressed
  848.     End If
  849.     tlbMain_ButtonClick b
  850. End Sub
  851. Private Sub LoadColumns()
  852. Dim rstCatDetails As Recordset
  853. Dim rstValueList As Recordset
  854. Dim IconIndex As Integer
  855. Dim col As JSGridEX.Column
  856. Dim picTemp As IPictureDisp
  857. On Error Resume Next
  858.     jGrid.Columns.Clear
  859.     Set rstCatDetails = m_db.OpenRecordset("CatalogDetails")
  860.     rstCatDetails.Index = "CatalogIndex"
  861.     rstCatDetails.Seek ">=", m_CatalogIndex
  862.     If Not rstCatDetails.NoMatch Then
  863.         Do Until rstCatDetails![CatalogId] <> m_CatalogIndex
  864.             If IsNull(rstCatDetails![DataField]) Then
  865.                 Set col = jGrid.Columns.Add()
  866.             Else
  867.                 Set col = jGrid.Columns.Add(, , , rstCatDetails![DataField])
  868.             End If
  869.             With col
  870.                 .Caption = rstCatDetails![Caption]
  871.                 .ColumnType = rstCatDetails![ColumnType]
  872.                 .EditType = rstCatDetails![EditType]
  873.                 .CardCaption = rstCatDetails![IsCardTitle]
  874.                 .CardIcon = rstCatDetails![IscardIcon]
  875.                 .DataField = rstCatDetails![DataField]
  876.                 .DefaultIcon = rstCatDetails![DefaultIcon]
  877.                 .FetchData = rstCatDetails![FetchData]
  878.                 .FetchIcon = rstCatDetails![FetchIcon]
  879.                 .Format = rstCatDetails![Format]
  880.                 .GroupEmptyStringCaption = rstCatDetails![GroupEmptyStringCaption]
  881.                 .GroupFormat = rstCatDetails![GroupFormat]
  882.                 .GroupPrefix = rstCatDetails![GroupPrefix]
  883.                 .HasValueList = rstCatDetails![HasValueList]
  884.                 .SortType = rstCatDetails![SortType]
  885.                 .TextAlignment = rstCatDetails![TextAlignment]
  886.                 .Width = rstCatDetails![Width]
  887.                 .AllowSizing = rstCatDetails![AllowSizing]
  888.                 .SortType = rstCatDetails![SortType]
  889.                 .Tag = rstCatDetails![Description]
  890.                 .Visible = True
  891.                 If .HasValueList Then
  892.                     Set rstValueList = m_db.OpenRecordset(rstCatDetails![ValueListRecordSource], dbOpenSnapshot)
  893.                     Do Until rstValueList.EOF
  894.                         IconIndex = 0
  895.                         If Not IsNull(rstValueList![PictureFile]) Then
  896.                             Set picTemp = LoadPicture(App.Path & "\Icons\" & rstValueList![PictureFile])
  897.                             If Not picTemp Is Nothing Then
  898.                                 jGrid.GridImages.Add picTemp
  899.                                 IconIndex = jGrid.GridImages.Count
  900.                             End If
  901.                         End If
  902.                         .ValueList.Add rstValueList![Value], rstValueList![Text], IconIndex
  903.                         rstValueList.MoveNext
  904.                     Loop
  905.                     Set rstValueList = Nothing
  906.                 End If
  907.             End With
  908.             rstCatDetails.MoveNext
  909.             If rstCatDetails.EOF Then Exit Do
  910.         Loop
  911.     End If
  912. End Sub
  913. Private Sub LoadCatalogFromRecordset()
  914. Dim rstCatalog As Recordset
  915. Dim DefaultView As Variant
  916. Dim i As Long
  917. On Error Resume Next
  918.     Set rstCatalog = m_db.OpenRecordset("Catalogs", dbOpenTable)
  919.     rstCatalog.Index = "PrimaryKey"
  920.     rstCatalog.Seek "=", m_CatalogIndex
  921.     If Not rstCatalog.NoMatch Then
  922.         With jGrid
  923.             .HoldFields
  924.             .RecordSource = rstCatalog![RecordSource]
  925.             .Rebind
  926.             LoadViews
  927.             DefaultView = rstCatalog![DefaultView]
  928.             If IsNull(DefaultView) Then
  929.                 cboStyle.ListIndex = 0
  930.             Else
  931.                 For i = 0 To cboStyle.ListCount - 1
  932.                     If cboStyle.ItemData(i) = DefaultView Then
  933.                         cboStyle.ListIndex = i
  934.                         Exit For
  935.                     End If
  936.                 Next
  937.             End If
  938.         End With
  939.     End If
  940. End Sub
  941. Private Sub LoadViews()
  942. Dim rstViews As Recordset
  943. Dim i As Integer
  944. On Error Resume Next
  945.     Set rstViews = m_db.OpenRecordset("Views", dbOpenTable)
  946.     rstViews.Index = "CatalogId"
  947.     rstViews.Seek "=", m_CatalogIndex
  948.     For i = 1 To cboStyle.ListCount - 1
  949.         Unload MnuViewStyle(i)
  950.     Next
  951.     cboStyle.Clear
  952.     If Not rstViews.NoMatch Then
  953.         Do Until rstViews![CatalogId] <> m_CatalogIndex
  954.             cboStyle.AddItem rstViews![Name]
  955.             cboStyle.ItemData(cboStyle.NewIndex) = rstViews![ViewId]
  956.             rstViews.MoveNext
  957.             If rstViews.EOF Then Exit Do
  958.         Loop
  959.     End If
  960.     MnuViewStyle(0).Caption = cboStyle.List(0)
  961.     For i = 1 To cboStyle.ListCount - 1
  962.         Load MnuViewStyle(i)
  963.         MnuViewStyle(i).Caption = cboStyle.List(i)
  964.         MnuViewStyle(i).Visible = True
  965.     Next
  966. End Sub
  967. Public Sub UnloadForm(FormKey As String)
  968.     mcolForms.Remove FormKey
  969. End Sub
  970. Private Sub tvwCatalog_NodeClick(ByVal Node As ComctlLib.Node)
  971.     Dim tmpIndex As Long
  972.     If Node Is Nothing Then Exit Sub
  973.     Set Node = tvwCatalog.SelectedItem
  974.     tmpIndex = CLng(Node.Tag)
  975.     If tmpIndex = m_CatalogIndex Then Exit Sub
  976.     Set imgCat.Picture = iml32.ListImages(Node.Image).ExtractIcon
  977.     m_CatalogIndex = tmpIndex
  978.     SetCatalog
  979. End Sub
  980. Private Sub EnableButtons(ByVal bEnable As Boolean)
  981. Dim b As Button
  982.     For Each b In tlbMain.Buttons
  983.         If b.Style = tbrDefault Or b.Style = tbrCheck Then
  984.             b.Enabled = bEnable
  985.         End If
  986.     Next
  987.     cmdNewRecord.Enabled = bEnable
  988. End Sub
  989. Private Function GetKeyFromBookmark(strPrefix As String, Bookmark As Variant) As String
  990. Dim strTemp As String
  991. Static NullCount As Long
  992. Dim i As Integer
  993.     If IsNull(Bookmark) Then
  994.         NullCount = NullCount + 1
  995.         strTemp = NullCount
  996.     Else
  997.         For i = LBound(Bookmark) To UBound(Bookmark)
  998.             strTemp = strTemp & Chr(Bookmark(i))
  999.         Next
  1000.     End If
  1001.     GetKeyFromBookmark = strPrefix & strTemp
  1002. End Function
  1003. Private Sub ShowRecord(Optional NewRecord As Boolean)
  1004. Dim strKey As String
  1005. Dim varBookmark As Variant
  1006. Dim RowIndex As Long
  1007. Dim frmTemp As Form
  1008. Dim rs As Recordset
  1009.     If m_CatalogIndex = 0 Then Exit Sub
  1010.     strKey = "Cat" & m_CatalogIndex & "-"
  1011.     If NewRecord Then
  1012.         varBookmark = Null
  1013.     Else
  1014.         RowIndex = jGrid.RowIndex(jGrid.Row)
  1015.         If RowIndex = 0 Then
  1016.             Exit Sub
  1017.         Else
  1018.             varBookmark = jGrid.RowBookmark(RowIndex)
  1019.         End If
  1020.     End If
  1021.     strKey = GetKeyFromBookmark(strKey, varBookmark)
  1022.     On Error Resume Next
  1023.     Set frmTemp = mcolForms.Item(strKey)
  1024.     If Err Then
  1025.         Select Case m_CatalogIndex
  1026.             Case CatalogCustomers
  1027.                 Set frmTemp = New frmCustomers
  1028.             Case CatalogSuppliers
  1029.                 Set frmTemp = New frmSuppliers
  1030.             Case CatalogEmployees
  1031.                 Set frmTemp = New frmEmployees
  1032.             Case CatalogProducts
  1033.                 Set frmTemp = New frmProducts
  1034.             Case CatalogOrders
  1035.                 Set frmTemp = New frmOrders
  1036.         End Select
  1037.         frmTemp.Key = strKey
  1038.         mcolForms.Add frmTemp, strKey
  1039.         Set rs = jGrid.Recordset
  1040.         If IsNull(varBookmark) Then
  1041.             frmTemp.NewRecord m_db, rs
  1042.         Else
  1043.             rs.Bookmark = varBookmark
  1044.             frmTemp.EditRecord m_db, rs
  1045.         End If
  1046.     Else
  1047.         If frmTemp.WindowState = vbMinimized Then
  1048.             frmTemp.WindowState = vbNormal
  1049.         End If
  1050.         frmTemp.SetFocus
  1051.     End If
  1052. End Sub
  1053. Private Sub CheckGroups()
  1054.     If jGrid.View = jgexTable Then
  1055.         mnuEXCol.Enabled = (jGrid.Groups.Count > 0)
  1056.     End If
  1057. End Sub
  1058. Private Sub CheckMnuViewStyle()
  1059. Dim mnu As Menu
  1060.     For Each mnu In MnuViewStyle
  1061.         mnu.Checked = (mnu.Index = cboStyle.ListIndex)
  1062.     Next
  1063. End Sub
  1064.