Function faIndex(row As Integer, col As Integer) As Long faIndex =row * MSHFlexGrid1.Cols + col End Function Sub Form_Load() Dim i as Integer ' Fill MSHFlexGrid with data using TextArray property. For i =MSHFlexGrid1.FixedRows to MSFlexGrid1.Rows - 1 ' ** column 1 MSHFlexGrid1.TextArray(faIndex(i, 1)) =RandomName() ' Column 2. MSHFlexGrid1.TextArray(faIndex(i, 2)) =RandomNumber() Next Private Sub Form1_Load () MSHFlexGrid1.Rows =8 MSHFlexGrid1.Cols =5 End SubPrivate Sub MSHFlexGrid1_Click () ' Put text in current cell. MSHFlexGrid1.Text ="Here" ' Put text in third row, third column. MSHFlexGrid1.Col =2 MSHFlexGrid1.Row =2 MSHFlexGrid1.Text ="There" End SubFrom MSDN
Private Sub MSHFG_Click() ' ************************************************ ' * 选择记录 ' ************************************************ dim Tstring as string With MSHFG Tstring=.TextMatrix(.Row, .col) End With End Sub
请测试:Private Sub MSHF_Click() MsgBox MSHF.Text End Sub呵呵,直接用Text属性就是用户点击的那个单元格的文本啦!
faIndex =row * MSHFlexGrid1.Cols + col
End Function
Sub Form_Load()
Dim i as Integer
' Fill MSHFlexGrid with data using TextArray property.
For i =MSHFlexGrid1.FixedRows to MSFlexGrid1.Rows - 1
' ** column 1
MSHFlexGrid1.TextArray(faIndex(i, 1)) =RandomName()
' Column 2.
MSHFlexGrid1.TextArray(faIndex(i, 2)) =RandomNumber()
Next
Private Sub Form1_Load ()
MSHFlexGrid1.Rows =8
MSHFlexGrid1.Cols =5
End SubPrivate Sub MSHFlexGrid1_Click ()
' Put text in current cell.
MSHFlexGrid1.Text ="Here"
' Put text in third row, third column.
MSHFlexGrid1.Col =2
MSHFlexGrid1.Row =2
MSHFlexGrid1.Text ="There"
End SubFrom MSDN
' ************************************************
' * 选择记录
' ************************************************
dim Tstring as string
With MSHFG
Tstring=.TextMatrix(.Row, .col) End With
End Sub
MsgBox MSHF.Text
End Sub呵呵,直接用Text属性就是用户点击的那个单元格的文本啦!
当前RECRODSET中的第ROWSEL-1的条记录即为你需要的值
MSHFlexGrid1.Col =5
MSHFlexGrid1.Row =7
MSHFlexGrid1.Text 2。DataGrid1网格当前单元格内容
DataGrid1.Columns(0).Text 第一列的值
DataGrid1.Columns(1).Text 第二列的值
msflexgrid.testarray