请问 如何能直接编辑MSHFlexGrid 的内容。
解决方案 »
- VB6居然提升了一名。。
- VB中数据库还原的问题(SQL)
- [chenhui530]Ring0下的病毒诊断分析程序终于完成了
- 用VB实现矩阵的计算,满意给100
- 砸锅卖铁,为了矢量图? 解决问题另开帖子再加分.
- listview的问题
- 怎样将一个数组清空,既没有组数也没有数据?急!
- datacombo控件的应用
- 如何使用split函数获得一个字符串中指定数量的字符然后打印???快啊@@@@@@@@@@@@@@@@###$!%^
- 我们用ACCESS+VBA作了一个东西。然后将这个库折分成数据和代码两部分(放在同一目录下),但这样的话,如果将这个库放到别人的机器上(目录不一定),存放代码的数据库就可能找不到存放数据的数据库了,怎么解决这个问题呢?也就是说如何建立两个库之间的关系呢?
- Access数据库中表结构的问题
- datagrid双击后,要把选中这行从列表中移去,啥办?
'本实例要在窗体上放一个MSHFlexGrid1,一个Text1
'------------------------------------------------Const ASC_ENTER = 13 '回车
Dim gRow As Integer
Dim gCol As Integer
Private Sub Form_Load()
MSHFlexGrid1.Cols = 10
MSHFlexGrid1.Rows = 10
Text1.BackColor = vbBlue
Text1.ForeColor = vbRed
Text1.Visible = False
End SubPrivate Sub MSHFlexGrid1_KeyPress(KeyAscii As Integer)
' Move the text box to the current grid cell:
Text1.Top = MSHFlexGrid1.CellTop + MSHFlexGrid1.Top
Text1.Left = MSHFlexGrid1.CellLeft + MSHFlexGrid1.Left
' Save the position of the grids Row and Col for later:
gRow = MSHFlexGrid1.Row
gCol = MSHFlexGrid1.Col
' Make text box same size as current grid cell:
Text1.Width = MSHFlexGrid1.CellWidth - 2 * Screen.TwipsPerPixelX
Text1.Height = MSHFlexGrid1.CellHeight - 2 * Screen.TwipsPerPixelY
' Transfer the grid cell text:
Text1.Text = MSHFlexGrid1.Text
' Show the text box:
Text1.Visible = True
Text1.ZOrder 0 ' 把 Text1 放到最前面!
Text1.SetFocus
' Redirect this KeyPress event to the text box:
If KeyAscii <> ASC_ENTER Then
SendKeys Chr$(KeyAscii)
End If
End SubPrivate Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = ASC_ENTER Then
MSHFlexGrid1.SetFocus
KeyAscii = 0
End If
End Sub
Private Sub Text1_LostFocus()
Dim tmpRow As Integer
Dim tmpCol As Integer
tmpRow = MSHFlexGrid1.Row
tmpCol = MSHFlexGrid1.Col
MSHFlexGrid1.Row = gRow
MSHFlexGrid1.Col = gCol
MSHFlexGrid1.Text = Text1.Text ' Transfer text back to grid.
Text1.SelStart = 0 ' Return caret to beginning.
Text1.Visible = False ' Disable text box.
MSHFlexGrid1.Row = tmpRow
MSHFlexGrid1.Col = tmpCol
End Sub