Skip to main content

Past Blast

Featured Products

Windows Mobile Developer Controls
Windows Mobile Developer Controls
Stay in touch using the DEVBUSS RSS feeds.
 

News

Windows Mobile Developer Controls
Sapphire Soltuions

eVB Database Viewer

Written by Jason Freih  [author's bio]  [read 64043 times]
Edited by Derek

Download the code

Page 1  Page 2  Page 3  Page 4  Page 5  Page 6 

When viewing the information in Grid View a text box appears at the top of the screen displaying the information in each cell as the users scrolls through the grid. This way the user can get a glimpse of the "big picture" as well as the full details in each cell.

Unfortunately in order to display the Grid we must create each row and column, as we read the recordset, field by field and record by record. The following code was used from the devBuzz code snippets area.

Private Sub DispGrid(sTableName As String)
'Display DB-Grid
On Error Resume Next
Dim i As Integer

'Hide grid while being populated, it will load faster
Grid1.Visible = False
Grid1.Clear

lblDispMsg.Caption = "Loading Grid Please Wait"
lblDispMsg.ForeColor = vbRed

Grid1.Cols = rsWorkingTbl.Fields.Count
Grid1.Rows = 1

Grid1.ColWidth(1) = 1000

If rsWorkingTbl.Fields.Count > 0 Then

For i = 0 To rsWorkingTbl.Fields.Count - 1
Grid1.Col = i
Grid1.Text = rsWorkingTbl.Fields(i).Name
Grid1.CellBackColor = &HC0C0C0
Next

Do While Not rsWorkingTbl.EOF
Grid1.Rows = Grid1.Rows + 1
Grid1.Row = Grid1.Rows - 1

For i = 0 To rsWorkingTbl.Fields.Count - 1
Grid1.Col = i
Grid1.Text = rsWorkingTbl.Fields(i)
Next

rsWorkingTbl.MoveNext
Loop

Grid1.Visible = True
Else
MsgBox "Sorry No Records"
End If
Grid1.Row = 0
Grid1.Col = 0

lblDispMsg.Caption = "BSB DataBase Analyzer"
End Sub

CODE 13 (Form)

As we scroll through the grid the txtBox text box gets updated with the highlighted value.

Private Sub Grid1_EnterCell()
'Dispaly contents of a cell as you move through the Grid
Dim sVar As Variant

sVar = Grid1.Text
txtBox = sVar
txtBox.Visible = True
End Sub

CODE 14 (Form)

When viewing the information on a record basis a grid is still used, except this time the left hand column contains the field names, and the right hand column contains the values.

The field names are derived from the MsysFields table, by looking at the table code in the MsysTables table, and then relating that code in the MsysFields we get all the field names, lengths and types. (The types are only ODBC types, there fore the exact type ie currency, vs. number fields is not distinguished both are simply interpreted as a number field)

Private Sub cmdViewRecs_Click()
'View One Record at a Time
Me.List1.Visible = False

'Open the rsWorkingTbl Record set with the LoadRecSet
'function location in MAIN Module
LoadRecSet
'Open Grid to view records on at a time
Grid1.Visible = False
rsWorkingTbl.MoveFirst
GridRec_Fill
txtBox.Height = 492
Me.txtBox.Visible = True
BtnShow ("000001111")
Me.lblDispMsg.Caption = "Use the buttons to navigate"
End Sub

Once we open the Recordset we fill in the Grid, in a similar fashion to the how we filled in the grid view. This time however the first column contains the field names, and the second columns contains the corresponding value.

Private Sub GridRec_Fill()
'Display DB-Grid For individual records
Dim sRec As String

'Hide the gird when you populate it, it will load, faster
'and the User won't get dizzy looking at it

Grid1.Visible = False
Grid1.Clear

Grid1.Cols = 2
Grid1.Rows = 1

Grid1.Col = 1
Grid1.ColWidth(1) = 2420
Grid1.Col = 0

rsRecords.MoveFirst

Do While Not rsRecords.EOF
sRec = rsRecords.Fields("FieldName")
Grid1.Col = 0
Grid1.Text = sRec

Grid1.Col = 1
If IsNull(rsWorkingTbl.Fields(sRec)) Then
Grid1.Text = " "
Else
Grid1.Text = rsWorkingTbl.Fields(sRec)
End If

rsRecords.MoveNext
'rsWorkingTbl.Movenext

Grid1.Rows = Grid1.Rows + 1
Grid1.Row = Grid1.Rows - 1
Loop

Grid1.Visible = True
lblDispMsg.Caption = "BSB DataBase Analyzer"
Grid1.Row = 0
Grid1.Col = 0

End Sub

CODE 15 (Form)

Previous Page  Next Page