物业公司退出小区:为MSHFlexGrid添加表格编辑功能
来源:百度文库 编辑:中财网 时间:2024/04/29 09:38:04
转载自:http://blog.csdn.net/lyserver/article/details/4188280
虽然MSHFlexGrid的功能比较强大,样式比较丰富,可惜它不支持数据编辑。我以前俺用TextBox实现了它的编辑功能,总算弥补了MSHFlexGrid的不足。
虽然MSHFlexGrid的功能比较强大,样式比较丰富,可惜它不支持数据编辑。我以前俺用TextBox实现了它的编辑功能,总算弥补了MSHFlexGrid的不足。
首先,新建一个标准EXE工程,然后, 在工程部件里选择“Microsoft Hierarchical Flex Grid Control 6.0 (OLEDB)”,在Form里添加一个MSHFlexGrid控件,命名为msGrid,再添加一个TextBox控件,命名为txtCell,最后在Form的代码窗口里粘贴以下代码,运行一下工程,一个支持数据编辑的表格就算大功告成了。
view plaincopy to clipboard?
- Option Explicit
- Private Sub Form_Load()
- Dim i As Long
- Me.ScaleMode = vbPixels
- msGrid.Rows = 10
- msGrid.Cols = 10
- For i = 1 To 9
- msGrid.TextMatrix(i, 0) = i
- msGrid.TextMatrix(0, i) = Chr(i + 64)
- Next
- msGrid.HighLight = flexHighlightNever
- msGrid.AllowBigSelection = False
- msGrid.SelectionMode = flexSelectionFree
- msGrid.FocusRect = flexFocusNone
- txtCell.Move -100, -100
- txtCell.BorderStyle = 0
- End Sub
- Private Sub msGrid_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
- If Button <> 1 Then Exit Sub
- msGrid.Redraw = False
- End Sub
- Private Sub msGrid_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
- If Button <> 1 Then Exit Sub
- msGrid.ColSel = msGrid.Col
- msGrid.RowSel = msGrid.Row
- msGrid.Redraw = True
- If msGrid.Row > msGrid.FixedRows - 1 And msGrid.Col > msGrid.FixedCols - 1 And msGrid.CellWidth > 0 And msGrid.CellHeight > 0 Then
- txtCell.Move msGrid.Left - 1 + msGrid.CellLeft / 15, msGrid.Top - 1 + msGrid.CellTop / 15, msGrid.CellWidth / 15, msGrid.CellHeight / 15
- txtCell.Tag = "No"
- txtCell.Text = msGrid.Text
- txtCell.Tag = ""
- txtCell.SetFocus
- End If
- End Sub
- Private Sub msGrid_Scroll()
- txtCell.Move -100, -100
- End Sub
- Private Sub txtCell_Change()
- If txtCell.Tag <> "No" And msGrid.Col >= msGrid.FixedCols And msGrid.Row >= msGrid.FixedRows Then
- msGrid.Text = txtCell.Text
- End If
- End Sub
- Private Sub txtCell_KeyDown(KeyCode As Integer, Shift As Integer)
- Select Case KeyCode
- Case 37
- If msGrid.Col > msGrid.FixedCols And txtCell.SelStart = 0 Then
- msGrid.Col = msGrid.Col - 1
- KeyCode = 0
- End If
- Case 38
- If msGrid.Row > msGrid.FixedRows And txtCell.SelStart = 0 Then
- msGrid.Row = msGrid.Row - 1
- KeyCode = 0
- End If
- Case 39
- If msGrid.Col < msGrid.Cols - 1 And txtCell.SelStart = Len(txtCell.Text) Then
- msGrid.Col = msGrid.Col + 1
- KeyCode = 0
- End If
- Case 40
- If msGrid.Row < msGrid.Rows - 1 And txtCell.SelStart = Len(txtCell.Text) Then
- msGrid.Row = msGrid.Row + 1
- KeyCode = 0
- End If
- Case 13
- If msGrid.Col < msGrid.Cols - 1 Then
- msGrid.Col = msGrid.Col + 1
- Else
- If msGrid.Row < msGrid.Rows - 1 Then msGrid.Row = msGrid.Row + 1
- msGrid.Col = msGrid.FixedCols
- End If
- KeyCode = 0
- Case 33
- msGrid.SetFocus
- SendKeys Chr(33)
- Case 34
- msGrid.SetFocus
- SendKeys Chr(34)
- End Select
- If KeyCode = 0 And msGrid.CellWidth > 0 And msGrid.CellHeight > 0 Then
- txtCell.Text = msGrid.Text
- txtCell.Move msGrid.Left - 1 + msGrid.CellLeft / 15, msGrid.Top - 1 + msGrid.CellTop / 15, msGrid.CellWidth / 15, msGrid.CellHeight / 15
- txtCell.SelStart = 0
- txtCell.SelLength = Len(txtCell.Text)
- End If
- End Sub
请问VB6.0中 添加的表格控件(MSHFlexgrid)在哪呀?找不到.
vb的MSHFlexGrid控件表格大小问题
如何添加表格标题
如何为幻灯片中的多媒体对象(如图片,表格等)添加动画?
北京的公司为员工办理三险,添加参险人员需要哪几张表格?
使用mshflexgrid,如何将新添加的记录显示在第一行?
如何用excel编辑表格
怎么在电脑编辑表格??
ASP 编辑添加提交
VB的MSHFlexGrid控键怎么实现复制功能,用粘贴板?Clipboard.SetText
请问百度为什麽不开放语法编辑??还有,为什麽不取消匿名这项功能?
比较专业的视频编辑制作,添加特效用什么视点采集卡为好?
求教MSN Spaces中日志如何在添加图片为背景下编辑文字
功能编辑桌子卖
IE“编辑”功能修改
用WORD文档编辑表格,怎样使将页面设置为横向的页面,从左到右编辑,需要按什么键?
何为考试所限用的“具有编辑功能的计算器”?
把EXCEL的表格做成asp表格该如何编辑?
如何添加右键功能?
添加 鼠标右键 功能
word中添加功能
QQ功能如何添加~
我用Micorosoft Excel编辑表格时??????
用文本形式编辑不用表格是什么意思