请教VB中如何把MSHFlexGrid的记录显示在textbox控件里呢
我用ADO连了access数据库,然后用MSHFlexGrid1把数据库的内容显示在MSHFlexGrid1控件上。我想点击MSHFlexGrid控件里面的一行,就在textbox控件里面把MSHFlexGrid1那一行的数据显示出来,请问该如何做呢?谢谢!
Set conn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
conn.Open "provider=microsoft.jet.oledb.4.0;data source= " & App.Path & "\vb.mdb"
rs.Open "select * from admin", conn, 1, 3
rs.MoveFirst
Label6.Caption = rs.RecordCount
Label3.Caption = rs.AbsolutePosition
Text1.Text = rs.Fields("username")
Text2.Text = rs.Fields("age")
Text3.Text = rs.Fields("password")
If rs.Fields("sex") = "男" Then
Option1.Value = True
Else
Option2.Value = True
End If
'rs.Close
'Set rs = Nothing
Set MSHFlexGrid1.DataSource = rs
[解决办法]
text1.text=mshflexgrid1.textmatrix(mshflexgrid1.row,1)
可以取得mshflexgrid某个单元格的值,mshflexgrid.textmatrix(row,col)
[解决办法]
private sub mshflexgrid1_click() with mshflexgrid1 text1.text=.textmatrix(.row,.col) end withend sub