0% found this document useful (0 votes)
22 views2 pages

Flex Grid

The document describes how to set properties and populate data in a flex grid control in Visual Basic. It includes code to set the grid properties like number of columns and rows, column widths, and cell text. The code also demonstrates how to programmatically add rows of tab-delimited data to the grid and set the starting cell. Keypress events are handled to allow only alphanumeric characters in cells.

Uploaded by

joshyjoy7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

Flex Grid

The document describes how to set properties and populate data in a flex grid control in Visual Basic. It includes code to set the grid properties like number of columns and rows, column widths, and cell text. The code also demonstrates how to programmatically add rows of tab-delimited data to the grid and set the starting cell. Keypress events are handled to allow only alphanumeric characters in cells.

Uploaded by

joshyjoy7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

http://www.pbdr.com/vbtips/gen/Article-UsingFlexGrids(1).

htm
Full code listing

Option Explicit


Private Sub SetGridProperties()

With grdInfo
.Cols = 4
.Rows = 1
.FocusRect = flexFocusHeavy
.SelectionMode = flexSelectionFree

.ColWidth(0) = 200
.ColWidth(1) = 1350
.ColWidth(2) = 1400
.ColWidth(3) = 1000

.Row = 0
.Col = 1
.Text = "First Name"

.Col = 2
.Text = "Last Name"

.Col = 3
.Text = "Middle Initial"
End With


End Sub


Private Sub FillData()

'add data
With grdInfo
.AddItem "1" & vbTab & "Michael" & vbTab & "Foster" & vbTab & "M"
.AddItem "2" & vbTab & "Angela" & vbTab & "Johnson" & vbTab & "K"
.AddItem "3" & vbTab & "Alex" & vbTab & "Smith" & vbTab & "H"
End With

'move to first cell
With grdInfo
.Col = 1
.Row = 1
End With


End Sub


Private Sub Form_Load()

Call SetGridProperties

Call FillData


End Sub


Private Sub grdInfo_KeyPress(KeyAscii As Integer)

Select Case KeyAscii
Case 65 To 90, 97 To 122, 48 To 57 'valid characters(letters & numbers
only)
grdInfo.Text = grdInfo.Text & Chr(KeyAscii)
Case 8 'backspace
If Len(grdInfo.Text) > 0 Then
grdInfo.Text = Left(grdInfo.Text, (Len(grdInfo.Text) - 1))
End If
Case Else 'invalid characters
KeyAscii = 0
Beep
End Select


End Sub

You might also like