在该示例中,用 AddItem 方法将 100 项添加到 MSFlexGrid 中。要试用此例,可以将代码粘贴到窗体(该窗体带有命名为 MSFlexGrid1 的 MSFlexGrid 控件)的声明部分,然后按下 F5 键,并单击该窗体。 Private Sub Form_Click () Dim Entry, i, Msg '声明变量。 Msg = _ "Choose OK to add 100 items to your MSFlexGrid." MsgBox Msg '显示消息。 MSFlexGrid1.Cols = 2 '每行有两个字符串。 For i = 1 To 100 '从 1 计数到 100。 Entry = "Entry " & Chr(9) & I '创建项。 MSFlexGrid1.AddItem Entry '添加项。 Next i Msg ="Choose OK to remove every other entry." MsgBox Msg '显示消息。 For i =1 To 50 '决定怎样删除 MSFlexGrid1.RemoveItem i '其它每一项。 Next I Msg ="Choose OK to clear all items." MsgBox Msg '显示消息。 MSFlexGrid1.Clear '清除列表框。 End Sub
remove之前要判断rows ,小于两行不行,只能用rows = 行数
晕ing,楼主是问这个问题吗?
Private Sub InsertBlankRow(ByVal intRowID As Integer)
Dim intRow As Integer
Dim intCol As Integer
intCol = 1
intRow = FGrid1.Rows - 1
FGrid1.Rows = FGrid1.Rows + 1
'move
While intRow > intRowID
intCol = 1
While intCol < FGrid1.Cols - 1
FGrid1.TextMatrix(intRow, intCol) = FGrid1.TextMatrix(intRow - 1, intCol)
intCol = intCol + 1
Wend
intRow = intRow - 1
Wend
'clear the row whose rowID=intRowID
intCol = 1
While intCol < FGrid1.Cols - 1
FGrid1.TextMatrix(intRow, intCol) = ""
intCol = intCol + 1
Wend
'Rewrite the RowID flags
intRow = 1
intCol = 0
While intRow < FGrid1.Rows - 1
FGrid1.TextMatrix(intRow, intCol) = CStr(intRow)
intRow = intRow + 1
Wend
End Sub
是access数据库吗
Private Sub Form_Click ()
Dim Entry, i, Msg '声明变量。
Msg = _
"Choose OK to add 100 items to your MSFlexGrid."
MsgBox Msg '显示消息。
MSFlexGrid1.Cols = 2 '每行有两个字符串。
For i = 1 To 100 '从 1 计数到 100。
Entry = "Entry " & Chr(9) & I '创建项。
MSFlexGrid1.AddItem Entry '添加项。
Next i
Msg ="Choose OK to remove every other entry."
MsgBox Msg '显示消息。
For i =1 To 50 '决定怎样删除
MSFlexGrid1.RemoveItem i '其它每一项。
Next I
Msg ="Choose OK to clear all items."
MsgBox Msg '显示消息。
MSFlexGrid1.Clear '清除列表框。
End Sub