home *** CD-ROM | disk | FTP | other *** search
Wrap
VERSION 5.00 Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.2#0"; "COMCTL32.OCX" Object = "{BA7155BB-813E-11D1-B8F4-0080ADA85B53}#1.0#0"; "JSGridEX.ocx" Begin VB.Form frmMain Caption = "The Janus GridEX - Advanced Sample - (Northwind Traders)" ClientHeight = 6045 ClientLeft = 330 ClientTop = 1860 ClientWidth = 8595 Icon = "frmMain.frx":0000 LinkTopic = "Form1" LockControls = -1 'True ScaleHeight = 6045 ScaleWidth = 8595 StartUpPosition = 2 'CenterScreen Begin ComctlLib.Toolbar tlbMain Align = 1 'Align Top Height = 420 Left = 0 TabIndex = 3 Top = 0 Width = 8595 _ExtentX = 15161 _ExtentY = 741 ButtonWidth = 609 ButtonHeight = 582 AllowCustomize = 0 'False Wrappable = 0 'False Appearance = 1 ImageList = "iml16" _Version = 327682 BeginProperty Buttons {0713E452-850A-101B-AFC0-4210102A8DA7} NumButtons = 15 BeginProperty Button1 {0713F354-850A-101B-AFC0-4210102A8DA7} Key = "" Object.Tag = "" Style = 3 MixedState = -1 'True EndProperty BeginProperty Button2 {0713F354-850A-101B-AFC0-4210102A8DA7} Key = "" Object.Tag = "" Style = 4 Object.Width = 1200 MixedState = -1 'True EndProperty BeginProperty Button3 {0713F354-850A-101B-AFC0-4210102A8DA7} Key = "Edit" Object.Tag = "" ImageIndex = 12 EndProperty BeginProperty Button4 {0713F354-850A-101B-AFC0-4210102A8DA7} Key = "" Object.Tag = "" Style = 3 MixedState = -1 'True EndProperty BeginProperty Button5 {0713F354-850A-101B-AFC0-4210102A8DA7} Key = "Summary" Object.ToolTipText = "View Summary..." Object.Tag = "" ImageIndex = 11 EndProperty BeginProperty Button6 {0713F354-850A-101B-AFC0-4210102A8DA7} Key = "Group" Object.ToolTipText = "Group by..." Object.Tag = "" ImageIndex = 7 EndProperty BeginProperty Button7 {0713F354-850A-101B-AFC0-4210102A8DA7} Key = "Sort" Object.ToolTipText = "Sort..." Object.Tag = "" ImageIndex = 8 EndProperty BeginProperty Button8 {0713F354-850A-101B-AFC0-4210102A8DA7} Key = "" Object.Tag = "" Style = 3 MixedState = -1 'True EndProperty BeginProperty Button9 {0713F354-850A-101B-AFC0-4210102A8DA7} Key = "ShowGroupByBox" Object.ToolTipText = "Group By Box" Object.Tag = "" ImageIndex = 9 Style = 1 Value = 1 EndProperty BeginProperty Button10 {0713F354-850A-101B-AFC0-4210102A8DA7} Key = "AllowAddNew" Object.ToolTipText = "Show Allow Add New Row" Object.Tag = "" ImageIndex = 10 Style = 1 Value = 1 EndProperty BeginProperty Button11 {0713F354-850A-101B-AFC0-4210102A8DA7} Key = "" Object.Tag = "" Style = 4 Object.Width = 2500 MixedState = -1 'True EndProperty BeginProperty Button12 {0713F354-850A-101B-AFC0-4210102A8DA7} Key = "MoveFirst" Object.ToolTipText = "Move first visible record" Object.Tag = "" ImageIndex = 13 EndProperty BeginProperty Button13 {0713F354-850A-101B-AFC0-4210102A8DA7} Key = "MovePrevious" Object.ToolTipText = "Move previous visible record" Object.Tag = "" ImageIndex = 14 EndProperty BeginProperty Button14 {0713F354-850A-101B-AFC0-4210102A8DA7} Key = "MoveNext" Object.ToolTipText = "Move next visible record" Object.Tag = "" ImageIndex = 15 EndProperty BeginProperty Button15 {0713F354-850A-101B-AFC0-4210102A8DA7} Key = "MoveLast" Object.ToolTipText = "Move last visible record" Object.Tag = "" ImageIndex = 16 EndProperty EndProperty Begin VB.CommandButton cmdNewRecord Appearance = 0 'Flat Caption = "New Record" BeginProperty Font Name = "Tahoma" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 330 Left = 120 TabIndex = 7 TabStop = 0 'False Top = 30 Width = 1200 End Begin VB.ComboBox cboStyle Appearance = 0 'Flat Height = 315 Left = 3720 Style = 2 'Dropdown List TabIndex = 4 Top = 45 Width = 2325 End End Begin ComctlLib.TreeView tvwCatalog Height = 4905 Left = 90 TabIndex = 0 Top = 1080 Width = 2295 _ExtentX = 4048 _ExtentY = 8652 _Version = 327682 HideSelection = 0 'False Indentation = 265 LabelEdit = 1 LineStyle = 1 Style = 7 ImageList = "iml16" Appearance = 1 BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} Name = "Tahoma" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty End Begin JSGridEX.GridEX jGrid Height = 4890 Left = 2415 TabIndex = 5 Top = 1080 Visible = 0 'False Width = 6150 _ExtentX = 10848 _ExtentY = 8625 MethodHoldFields= -1 'True AllowDelete = -1 'True MaskColor = 16711935 ImageCount = 5 ImagePicture1 = "frmMain.frx":030A ImagePicture2 = "frmMain.frx":0624 ImagePicture3 = "frmMain.frx":093E ImagePicture4 = "frmMain.frx":0C58 ImagePicture5 = "frmMain.frx":0F72 ColumnCount = 2 CardCaption1 = -1 'True ColEditType1 = 3 AllowAddNew = -1 'True ColumnHeaderHeight= 330 End Begin VB.PictureBox picMain Height = 4890 Left = 2415 ScaleHeight = 322 ScaleMode = 3 'Pixel ScaleWidth = 406 TabIndex = 6 Top = 1080 Width = 6150 Begin VB.Image imglogo Height = 1815 Left = 4065 Picture = "frmMain.frx":128C Top = 150 Width = 1935 End End Begin ComctlLib.ImageList iml16 Left = 7590 Top = 480 _ExtentX = 1005 _ExtentY = 1005 BackColor = -2147483643 ImageWidth = 16 ImageHeight = 16 MaskColor = 12632256 _Version = 327682 BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7} NumListImages = 16 BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "frmMain.frx":2557 Key = "" EndProperty BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "frmMain.frx":2871 Key = "" EndProperty BeginProperty ListImage3 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "frmMain.frx":2B8B Key = "" EndProperty BeginProperty ListImage4 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "frmMain.frx":2EA5 Key = "" EndProperty BeginProperty ListImage5 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "frmMain.frx":31BF Key = "" EndProperty BeginProperty ListImage6 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "frmMain.frx":34D9 Key = "" EndProperty BeginProperty ListImage7 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "frmMain.frx":37F3 Key = "Group" Object.Tag = "Group" EndProperty BeginProperty ListImage8 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "frmMain.frx":3B0D Key = "Sort" EndProperty BeginProperty ListImage9 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "frmMain.frx":3E27 Key = "" EndProperty BeginProperty ListImage10 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "frmMain.frx":4141 Key = "" EndProperty BeginProperty ListImage11 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "frmMain.frx":445B Key = "" EndProperty BeginProperty ListImage12 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "frmMain.frx":4775 Key = "" EndProperty BeginProperty ListImage13 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "frmMain.frx":4A8F Key = "" EndProperty BeginProperty ListImage14 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "frmMain.frx":4DA9 Key = "" EndProperty BeginProperty ListImage15 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "frmMain.frx":50C3 Key = "" EndProperty BeginProperty ListImage16 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "frmMain.frx":53DD Key = "" EndProperty EndProperty End Begin VB.Label lblfront AutoSize = -1 'True BackColor = &H80000010& BackStyle = 0 'Transparent Caption = "Northwind Traders" BeginProperty Font Name = "Tahoma" Size = 18 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = &H80000005& Height = 435 Left = 180 TabIndex = 2 Top = 495 Width = 2970 End Begin ComctlLib.ImageList iml32 Left = 8175 Top = 480 _ExtentX = 1005 _ExtentY = 1005 BackColor = -2147483643 ImageWidth = 32 ImageHeight = 32 MaskColor = 12632256 _Version = 327682 BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7} NumListImages = 6 BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "frmMain.frx":56F7 Key = "" EndProperty BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "frmMain.frx":5A11 Key = "" EndProperty BeginProperty ListImage3 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "frmMain.frx":5D2B Key = "" EndProperty BeginProperty ListImage4 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "frmMain.frx":6045 Key = "" EndProperty BeginProperty ListImage5 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "frmMain.frx":635F Key = "" EndProperty BeginProperty ListImage6 {0713E8C3-850A-101B-AFC0-4210102A8DA7} Picture = "frmMain.frx":6679 Key = "" EndProperty EndProperty End Begin VB.Image imgCat Height = 480 Left = 7035 Picture = "frmMain.frx":6993 Top = 480 Width = 480 End Begin VB.Label lblback BackColor = &H80000010& Height = 555 Left = 90 TabIndex = 1 Top = 450 Width = 7530 End Begin VB.Menu mnuFile Caption = "File" Begin VB.Menu mnuExit Caption = "Exit" End End Begin VB.Menu mnuView Caption = "View" Begin VB.Menu mnuCurrentView Caption = "CurrentView" Begin VB.Menu MnuViewStyle Caption = "" Index = 0 End End Begin VB.Menu mnuViewSep Caption = "-" End Begin VB.Menu mnushow Caption = "Show Fields..." End Begin VB.Menu mnusort Caption = "Sort..." End Begin VB.Menu mnugroup Caption = "Group By..." End Begin VB.Menu mnuformat Caption = "Format View..." End Begin VB.Menu mnuEXCol Caption = "Expand/Collapse Groups" Begin VB.Menu mnucolall Caption = "Collapse All" End Begin VB.Menu mnuexpall Caption = "Expand All" End End Begin VB.Menu mnuSum Caption = "View Summary..." End Begin VB.Menu mnusep1 Caption = "-" End Begin VB.Menu mnugbBox Caption = "Group By Box" Checked = -1 'True End End Begin VB.Menu mnuHelp Caption = "Help" Begin VB.Menu mnuAbout Caption = "About" End End Attribute VB_Name = "frmMain" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Option Compare Text Dim m_CurrentView As Long Dim m_CatalogIndex As Long Dim m_db As Database Dim m_LastBaseIcon As Integer Dim mvarBookmark As Variant Dim mcolForms As New Collection Public Sub OnRecordUpdate(ByVal CatalogIndex As Integer, Bookmark As Variant) If m_CatalogIndex = CatalogIndex Then jGrid.Refresh If IsNull(Bookmark) Then jGrid.SearchNewRecords Else jGrid.MoveToBookmark Bookmark jGrid.Update End If End If End Sub Private Sub cboStyle_Click() Dim rstViews As Recordset Dim rsViewDetails As Recordset Dim rsCatalogDetails As Recordset Dim col As Column Dim lngColumnId As Long Dim IsTableView As Boolean If cboStyle.ListIndex = -1 Then Exit Sub Screen.MousePointer = 11 jGrid.Visible = False m_CurrentView = cboStyle.ItemData(cboStyle.ListIndex) Set rstViews = m_db.OpenRecordset("Views", dbOpenTable) Set rsViewDetails = m_db.OpenRecordset("ViewDetails", dbOpenTable) rsViewDetails.Index = "PrimaryKey" rstViews.Index = "PrimaryKey" rstViews.Seek "=", m_CurrentView If Not rstViews.NoMatch Then With jGrid .View = rstViews![GridView] With .Font .Name = rstViews![FontName] .Size = rstViews![FontSize] .Bold = rstViews![FontBold] .Italic = rstViews![FontItalic] .Strikethrough = rstViews![FontStrikethru] .Underline = rstViews![FontUnderline] End With With .ColumnHeaderFont .Name = rstViews![HeaderFontName] .Size = rstViews![HeaderFontSize] .Bold = rstViews![HeaderFontBold] .Italic = rstViews![HeaderFontItalic] .Strikethrough = rstViews![HeaderFontStrikethru] .Underline = rstViews![HeaderFontUnderline] End With .ForeColorHeader = rstViews![HeaderFontColor] .ForeColor = rstViews![FontColor] .GridLines = rstViews![GridLines] GroupByBoxVisible rstViews![ShowGroupByBox] .AllowEdit = rstViews![AllowEdit] AllowAddNew rstViews![AllowAddNew] .CardWidth = rstViews![CardWith] .CardCaptionPrefix = Format(rstViews![CardPrefix]) Set rsCatalogDetails = m_db.OpenRecordset("CatalogDetails", dbOpenTable) rsCatalogDetails.Index = "CatalogIndex" For Each col In .Columns rsCatalogDetails.Seek "=", m_CatalogIndex, col.Index If Not rsCatalogDetails.NoMatch Then lngColumnId = rsCatalogDetails![ColumnID] Else lngColumnId = 0 End If rsViewDetails.Seek "=", m_CurrentView, lngColumnId If Not rsViewDetails.NoMatch Then With col .Visible = rsViewDetails![Visible] .TextAlignment = rsViewDetails![TextAlignment] .Width = rsViewDetails![Width] .ColPosition = rsViewDetails![Position] End With End If Next With .FmtConditions .Clear .ShowGroupConditionCount = rstViews![ShowGroupConditionCount] .ApplyGroupCondition = rstViews![ApplyGroupCondition] .GroupConditionCountTitle = Format(rstViews![GroupConditionCountTitle]) End With 'Load FormatConditions Dim rsConditions As Recordset Dim fmtCon As FmtCondition Dim fmtStyle As FormatStyle Set rsConditions = m_db.OpenRecordset("ViewFormatConditions", dbOpenTable) rsConditions.Index = "ViewIndex" rsConditions.Seek ">=", m_CurrentView If Not rsConditions.NoMatch Then Do Until rsConditions.EOF If rsConditions![ViewId] <> m_CurrentView Then Exit Do If rsConditions![Index] = 0 Then Set fmtCon = .FmtConditions.GroupCondition fmtCon.ColIndex = rsConditions![ColIndex] fmtCon.Operator = rsConditions![Operator] fmtCon.Value1 = rsConditions![Value1] fmtCon.Value2 = rsConditions![Value2] Else Set fmtCon = .FmtConditions.Add(rsConditions![ColIndex], rsConditions![Operator], rsConditions![Value1], rsConditions![Value2]) End If Set fmtStyle = fmtCon.FormatStyle With fmtStyle .FontBold = rsConditions![FontBold] .FontItalic = rsConditions![FontItalic] .FontStrikethru = rsConditions![FontStrikethru] .FontUnderline = rsConditions![FontUnderline] .ForeColor = rsConditions![ForeColor] End With rsConditions.MoveNext Loop End If 'Load SortKeys in View Dim rsSortKeys As Recordset .SortKeys.Clear Set rsSortKeys = m_db.OpenRecordset("ViewSortKeys", dbOpenTable) rsSortKeys.Index = "PrimaryKey" rsSortKeys.Seek ">=", m_CurrentView If Not rsSortKeys.NoMatch Then Do Until rsSortKeys.EOF If rsSortKeys![ViewId] <> m_CurrentView Then Exit Do .SortKeys.Add rsSortKeys![ColIndex], rsSortKeys![SortOrder] rsSortKeys.MoveNext Loop End If 'Load Groups in View Dim rsGroups As Recordset .Groups.Clear Set rsGroups = m_db.OpenRecordset("ViewGroups", dbOpenTable) rsGroups.Index = "PrimaryKey" rsGroups.Seek ">=", m_CurrentView If Not rsGroups.NoMatch Then Do Until rsGroups.EOF If rsGroups![ViewId] <> m_CurrentView Then Exit Do .Groups.Add rsGroups![ColIndex], rsGroups![SortOrder] rsGroups.MoveNext Loop End If End With End If IsTableView = (jGrid.View = jgexTable) tlbMain.Buttons("ShowGroupByBox").Enabled = IsTableView tlbMain.Buttons("Group").Enabled = IsTableView tlbMain.Buttons("AllowAddNew").Enabled = IsTableView mnugbBox.Enabled = IsTableView mnugroup.Visible = IsTableView mnuEXCol.Visible = IsTableView CheckGroups CheckMnuViewStyle Screen.MousePointer = 0 jGrid.Visible = True jGrid.SetFocus End Sub Private Sub cmdNewRecord_Click() ShowRecord True End Sub Private Sub Form_Load() m_LastBaseIcon = jGrid.GridImages.Count LoadCatalogSettings SetCatalog End Sub Private Sub Form_Resize() On Error Resume Next Dim i As Long i = ScaleWidth - 650 If i < lblfront.Left + lblfront.Width + 60 Then i = lblfront.Left + lblfront.Width + 60 imgCat.Move i, imgCat.Top, imgCat.Width, imgCat.Height lblback.Move 30, lblback.Top, ScaleWidth - 60, lblback.Height tvwCatalog.Move 30, lblback.Top + lblback.Height + 60, tvwCatalog.Width, ScaleHeight - tvwCatalog.Top - 60 i = tvwCatalog.Left + 60 + tvwCatalog.Width jGrid.Move i, tvwCatalog.Top, ScaleWidth - i - 30, ScaleHeight - tvwCatalog.Top - 60 With jGrid picMain.Move .Left, .Top, .Width, .Height End With End Sub Private Sub Form_Unload(Cancel As Integer) Dim frm As Object On Error GoTo EH_Unload For Each frm In mcolForms Unload frm Next Exit Sub EH_Unload: MsgBox Err.Description End Sub Private Sub jGrid_AfterGroupChange() CheckGroups End Sub Private Sub jGrid_BeforeGroupChange(Group As JSGridEX.Group, ByVal ChangeOperation As jgexGroupChange, ByVal GroupPosition As Integer, Cancel As Boolean) Dim col As Column Dim rstCatDetails As Recordset If ChangeOperation = jgexGroupInsert Then Set col = jGrid.Columns(Group.ColIndex) Set rstCatDetails = m_db.OpenRecordset("CatalogDetails", dbOpenTable) rstCatDetails.Index = "CatalogIndex" rstCatDetails.Seek "=", m_CatalogIndex, col.Index If Not rstCatDetails.NoMatch Then If Not rstCatDetails![AllowGroup] Then MsgBox "You can not group items by this field.", vbInformation, "Advanced Sample" Cancel = True End If End If End If End Sub Private Sub jGrid_ColumnHeaderClick(Column As JSGridEX.Column) Dim rstCatDetails As Recordset Dim grTemp As JSGridEX.Group If Column.IsGrouped Then For Each grTemp In jGrid.Groups If grTemp.ColIndex = Column.Index Then jGrid_GroupByBoxHeaderClick grTemp End If Next Else If Column.SortOrder = 0 Then Set rstCatDetails = m_db.OpenRecordset("CatalogDetails", dbOpenTable) rstCatDetails.Index = "CatalogIndex" rstCatDetails.Seek "=", m_CatalogIndex, Column.Index If Not rstCatDetails.NoMatch Then If Not rstCatDetails![AllowSort] Then Exit Sub End If End If jGrid.SortKeys.Clear jGrid.SortKeys.Add Column.Index, 1 Else If Column.SortOrder = 1 Then jGrid.SortKeys.Clear jGrid.SortKeys.Add Column.Index, -1 Else jGrid.SortKeys.Clear jGrid.SortKeys.Add Column.Index, 1 End If End If End If End Sub Private Sub jGrid_DblClick() ShowRecord End Sub Private Sub jGrid_GroupByBoxHeaderClick(Group As JSGridEX.Group) Screen.MousePointer = 11 Group.SortOrder = -Group.SortOrder jGrid.RefreshGroups Screen.MousePointer = 0 End Sub Private Sub lblback_DblClick() Static Collapsed As Boolean If Collapsed Then jGrid.ExpandAll Else jGrid.CollapseAll End If Collapsed = Not Collapsed End Sub Private Sub mnuAbout_Click() frmAbout.Show 1 End Sub Private Sub mnucolall_Click() jGrid.CollapseAll End Sub Private Sub mnuExit_Click() Unload Me End Sub Private Sub mnuexpall_Click() jGrid.ExpandAll End Sub Private Sub mnuformat_Click() If Not jGrid.Visible Then Exit Sub If jGrid.View = jgexTable Then frmTableview.FormatGrid jGrid Else frmCardView.FormatGrid jGrid End If End Sub Private Sub mnugbBox_Click() mnugbBox.Checked = Not mnugbBox.Checked GroupByBoxVisible mnugbBox.Checked End Sub Private Sub mnugroup_Click() frmGroupBy.GroupGrid jGrid CheckGroups End Sub Private Sub mnushow_Click() If Not jGrid.Visible Then Exit Sub frmShowfields.ShowFields jGrid End Sub Private Sub mnusort_Click() If Not jGrid.Visible Then Exit Sub frmSort.SortGrid jGrid End Sub Private Sub mnuSum_Click() frmSummary.ShowSummary jGrid End Sub Private Sub MnuViewStyle_Click(Index As Integer) cboStyle.ListIndex = Index End Sub Private Sub tlbMain_ButtonClick(ByVal Button As ComctlLib.Button) Select Case Button.Key Case "Edit" ShowRecord Case "Group" If Not jGrid.Visible Then Exit Sub frmGroupBy.GroupGrid jGrid Case "Sort" If Not jGrid.Visible Then Exit Sub frmSort.SortGrid jGrid Case "ShowGroupByBox" jGrid.GroupByBoxVisible = (Button.Value = tbrPressed) mnugbBox.Checked = (Button.Value = tbrPressed) Case "AllowAddNew" jGrid.AllowAddNew = (Button.Value = tbrPressed) Case "Summary" frmSummary.ShowSummary jGrid Case "MoveFirst" jGrid.MoveFirst jGrid.SetFocus Case "MoveLast" jGrid.MoveLast jGrid.SetFocus Case "MovePrevious" jGrid.MovePrevious jGrid.SetFocus Case "MoveNext" jGrid.MoveNext jGrid.SetFocus End Select End Sub Private Sub tvwCatalog_Click() tvwCatalog_NodeClick tvwCatalog.SelectedItem End Sub Private Sub LoadCatalogSettings() Dim rstCatalogs As Recordset Dim nod As Node Dim lngParentIndex As Long Dim i As Integer Dim dbName As String dbName = App.Path & "\NWind.mdb" jGrid.DatabaseName = dbName Set m_db = OpenDatabase(dbName) Set rstCatalogs = m_db.OpenRecordset("Catalogs", dbOpenTable) m_CatalogIndex = -1 Set nod = tvwCatalog.Nodes.Add(, , , "Northwind Traders", 1) nod.Expanded = True nod.Tag = 0 lngParentIndex = nod.Index Do Until rstCatalogs.EOF Set nod = tvwCatalog.Nodes.Add(lngParentIndex, tvwChild, , rstCatalogs![Name], CInt(rstCatalogs![IconIndex])) nod.Tag = rstCatalogs![CatalogId] rstCatalogs.MoveNext Loop tvwCatalog.Nodes(lngParentIndex).Selected = True End Sub Private Sub SetCatalog() Dim Node As Node Dim i As Integer Dim c As JSGridEX.Column Set Node = tvwCatalog.SelectedItem m_CatalogIndex = CLng(Node.Tag) lblfront.Caption = Node.Text jGrid.Visible = False For i = jGrid.GridImages.Count To m_LastBaseIcon + 1 Step -1 jGrid.GridImages.Remove i Next If m_CatalogIndex = 0 Then mnuView.Enabled = False EnableButtons False picMain.Visible = True cboStyle.Clear cboStyle.Enabled = False jGrid.Visible = False Else mnuView.Enabled = True EnableButtons True picMain.Visible = False LoadColumns LoadCatalogFromRecordset cboStyle.Enabled = True jGrid.Visible = True jGrid.Row = 1 End If End Sub Private Sub GroupByBoxVisible(ByVal Value As Boolean) Dim b As ComctlLib.Button Set b = tlbMain.Buttons("ShowGroupByBox") If (b.Value = tbrPressed) = Value Then Exit Sub If Value Then b.Value = tbrPressed Else b.Value = tbrUnpressed End If tlbMain_ButtonClick b End Sub Public Sub AllowAddNew(ByVal Value As Boolean) Dim b As ComctlLib.Button Set b = tlbMain.Buttons("AllowAddNew") If (b.Value = tbrPressed) = Value Then Exit Sub If Value Then b.Value = tbrPressed Else b.Value = tbrUnpressed End If tlbMain_ButtonClick b End Sub Private Sub LoadColumns() Dim rstCatDetails As Recordset Dim rstValueList As Recordset Dim IconIndex As Integer Dim col As JSGridEX.Column Dim picTemp As IPictureDisp On Error Resume Next jGrid.Columns.Clear Set rstCatDetails = m_db.OpenRecordset("CatalogDetails") rstCatDetails.Index = "CatalogIndex" rstCatDetails.Seek ">=", m_CatalogIndex If Not rstCatDetails.NoMatch Then Do Until rstCatDetails![CatalogId] <> m_CatalogIndex If IsNull(rstCatDetails![DataField]) Then Set col = jGrid.Columns.Add() Else Set col = jGrid.Columns.Add(, , , rstCatDetails![DataField]) End If With col .Caption = rstCatDetails![Caption] .ColumnType = rstCatDetails![ColumnType] .EditType = rstCatDetails![EditType] .CardCaption = rstCatDetails![IsCardTitle] .CardIcon = rstCatDetails![IscardIcon] .DataField = rstCatDetails![DataField] .DefaultIcon = rstCatDetails![DefaultIcon] .FetchData = rstCatDetails![FetchData] .FetchIcon = rstCatDetails![FetchIcon] .Format = rstCatDetails![Format] .GroupEmptyStringCaption = rstCatDetails![GroupEmptyStringCaption] .GroupFormat = rstCatDetails![GroupFormat] .GroupPrefix = rstCatDetails![GroupPrefix] .HasValueList = rstCatDetails![HasValueList] .SortType = rstCatDetails![SortType] .TextAlignment = rstCatDetails![TextAlignment] .Width = rstCatDetails![Width] .AllowSizing = rstCatDetails![AllowSizing] .SortType = rstCatDetails![SortType] .Tag = rstCatDetails![Description] .Visible = True If .HasValueList Then Set rstValueList = m_db.OpenRecordset(rstCatDetails![ValueListRecordSource], dbOpenSnapshot) Do Until rstValueList.EOF IconIndex = 0 If Not IsNull(rstValueList![PictureFile]) Then Set picTemp = LoadPicture(App.Path & "\Icons\" & rstValueList![PictureFile]) If Not picTemp Is Nothing Then jGrid.GridImages.Add picTemp IconIndex = jGrid.GridImages.Count End If End If .ValueList.Add rstValueList![Value], rstValueList![Text], IconIndex rstValueList.MoveNext Loop Set rstValueList = Nothing End If End With rstCatDetails.MoveNext If rstCatDetails.EOF Then Exit Do Loop End If End Sub Private Sub LoadCatalogFromRecordset() Dim rstCatalog As Recordset Dim DefaultView As Variant Dim i As Long On Error Resume Next Set rstCatalog = m_db.OpenRecordset("Catalogs", dbOpenTable) rstCatalog.Index = "PrimaryKey" rstCatalog.Seek "=", m_CatalogIndex If Not rstCatalog.NoMatch Then With jGrid .HoldFields .RecordSource = rstCatalog![RecordSource] .Rebind LoadViews DefaultView = rstCatalog![DefaultView] If IsNull(DefaultView) Then cboStyle.ListIndex = 0 Else For i = 0 To cboStyle.ListCount - 1 If cboStyle.ItemData(i) = DefaultView Then cboStyle.ListIndex = i Exit For End If Next End If End With End If End Sub Private Sub LoadViews() Dim rstViews As Recordset Dim i As Integer On Error Resume Next Set rstViews = m_db.OpenRecordset("Views", dbOpenTable) rstViews.Index = "CatalogId" rstViews.Seek "=", m_CatalogIndex For i = 1 To cboStyle.ListCount - 1 Unload MnuViewStyle(i) Next cboStyle.Clear If Not rstViews.NoMatch Then Do Until rstViews![CatalogId] <> m_CatalogIndex cboStyle.AddItem rstViews![Name] cboStyle.ItemData(cboStyle.NewIndex) = rstViews![ViewId] rstViews.MoveNext If rstViews.EOF Then Exit Do Loop End If MnuViewStyle(0).Caption = cboStyle.List(0) For i = 1 To cboStyle.ListCount - 1 Load MnuViewStyle(i) MnuViewStyle(i).Caption = cboStyle.List(i) MnuViewStyle(i).Visible = True Next End Sub Public Sub UnloadForm(FormKey As String) mcolForms.Remove FormKey End Sub Private Sub tvwCatalog_NodeClick(ByVal Node As ComctlLib.Node) Dim tmpIndex As Long If Node Is Nothing Then Exit Sub Set Node = tvwCatalog.SelectedItem tmpIndex = CLng(Node.Tag) If tmpIndex = m_CatalogIndex Then Exit Sub Set imgCat.Picture = iml32.ListImages(Node.Image).ExtractIcon m_CatalogIndex = tmpIndex SetCatalog End Sub Private Sub EnableButtons(ByVal bEnable As Boolean) Dim b As Button For Each b In tlbMain.Buttons If b.Style = tbrDefault Or b.Style = tbrCheck Then b.Enabled = bEnable End If Next cmdNewRecord.Enabled = bEnable End Sub Private Function GetKeyFromBookmark(strPrefix As String, Bookmark As Variant) As String Dim strTemp As String Static NullCount As Long Dim i As Integer If IsNull(Bookmark) Then NullCount = NullCount + 1 strTemp = NullCount Else For i = LBound(Bookmark) To UBound(Bookmark) strTemp = strTemp & Chr(Bookmark(i)) Next End If GetKeyFromBookmark = strPrefix & strTemp End Function Private Sub ShowRecord(Optional NewRecord As Boolean) Dim strKey As String Dim varBookmark As Variant Dim RowIndex As Long Dim frmTemp As Form Dim rs As Recordset If m_CatalogIndex = 0 Then Exit Sub strKey = "Cat" & m_CatalogIndex & "-" If NewRecord Then varBookmark = Null Else RowIndex = jGrid.RowIndex(jGrid.Row) If RowIndex = 0 Then Exit Sub Else varBookmark = jGrid.RowBookmark(RowIndex) End If End If strKey = GetKeyFromBookmark(strKey, varBookmark) On Error Resume Next Set frmTemp = mcolForms.Item(strKey) If Err Then Select Case m_CatalogIndex Case CatalogCustomers Set frmTemp = New frmCustomers Case CatalogSuppliers Set frmTemp = New frmSuppliers Case CatalogEmployees Set frmTemp = New frmEmployees Case CatalogProducts Set frmTemp = New frmProducts Case CatalogOrders Set frmTemp = New frmOrders End Select frmTemp.Key = strKey mcolForms.Add frmTemp, strKey Set rs = jGrid.Recordset If IsNull(varBookmark) Then frmTemp.NewRecord m_db, rs Else rs.Bookmark = varBookmark frmTemp.EditRecord m_db, rs End If Else If frmTemp.WindowState = vbMinimized Then frmTemp.WindowState = vbNormal End If frmTemp.SetFocus End If End Sub Private Sub CheckGroups() If jGrid.View = jgexTable Then mnuEXCol.Enabled = (jGrid.Groups.Count > 0) End If End Sub Private Sub CheckMnuViewStyle() Dim mnu As Menu For Each mnu In MnuViewStyle mnu.Checked = (mnu.Index = cboStyle.ListIndex) Next End Sub