Article ID: 190225
Article Last Modified on 3/2/2005
Option Explicit
Dim iFixedRows As Integer
Dim iFixedCols As Integer
Private Sub Command1_Click()
iFixedCols = iFixedCols + 1
If iFixedCols > MSFlexGrid1.Cols - 1 Then
iFixedCols = MSFlexGrid1.Cols - 1
MsgBox "No more columns to fix"
Else
MSFlexGrid1.FixedCols = iFixedCols
End If
End Sub
Private Sub Command2_Click()
iFixedCols = iFixedCols - 1
If iFixedCols < 0 Then
iFixedCols = 0
MsgBox "No more Columns to unfix"
Else
MSFlexGrid1.FixedCols = iFixedCols
End If
End Sub
Private Sub Command3_Click()
iFixedRows = iFixedRows + 1
If iFixedRows > MSFlexGrid1.Rows - 1 Then
iFixedRows = MSFlexGrid1.Rows - 1
MsgBox "No more rows to fix"
Else
MSFlexGrid1.FixedRows = iFixedRows
End If
End Sub
Private Sub Command4_Click()
iFixedRows = iFixedRows - 1
If iFixedRows< 0 Then
iFixedRows = 0
MsgBox "No more rows to unfix"
Else
MSFlexGrid1.FixedRows = iFixedRows
End If
End Sub
Private Sub Form_Load()
Command1.Caption = "Increment fixed Columns"
Command2.Caption = "Decrease fixed Columns"
Command3.Caption = "Increment fixed Rows"
Command4.Caption = "Decrease fixed Rows"
FillFlexGrid 'call sub that puts data into grid
iFixedRows = MSFlexGrid1.FixedRows
iFixedCols = MSFlexGrid1.FixedCols
End Sub
Private Sub FillFlexGrid()
Dim sEntry As String
With MSFlexGrid1
.Cols = 5 'set the number of columns
' Set FixedRows to 0 so you can use AddItem. You can't
' use AddItem with a FixedRow. You have to use the Text property
.FixedRows = 0
.MergeCells = flexMergeFree 'Set the MergeCells property.
.Font.Name = "fixedsys"
.Font.Size = 8
.Row = 0
.Col = 0
.ColWidth(0) = 1750
' Add some data to the grid using AddItem.
sEntry = "Region" & vbTab & "Region" & vbTab & "Employee"
.AddItem sEntry, 0
sEntry = "Northwest" & vbTab & "Bats" & vbTab & "Bats"
.AddItem sEntry, 1
sEntry = "Northwest" & vbTab & "Whahoos"
.AddItem sEntry, 2
sEntry = "Northwest" & vbTab & "Whahoos"
.AddItem sEntry, 3
sEntry = "Northwest" & vbTab & "Sharks"
.AddItem sEntry, 4
sEntry = "Southeast" & vbTab & "Panthers"
.AddItem sEntry, 5
sEntry = "Southeast" & vbTab & "Panthers"
.AddItem sEntry, 6
sEntry = "Southeast" & vbTab & "Desktops"
.AddItem sEntry, 7
sEntry = "Southeast" & vbTab & "Desktops"
.AddItem sEntry, 8
sEntry = "Mid-Atlantic" & vbTab & "VSx7"
.AddItem sEntry, 9
sEntry = "Mid-Atlantic" & vbTab & "VSx7"
.AddItem sEntry, 10
' Set the rows and columns you want to merge.
.MergeCol(0) = True 'First Column in grid
.MergeCol(1) = True 'Second Column in grid
.MergeRow(0) = True 'First Row in Grid
.MergeRow(1) = True 'Second Row in Grid
' Set the fixed columns and rows.
.FixedCols = 1
.FixedRows = 1
End With
End Sub
Keywords: kbhowto kbctrl KB190225