MSHflexGrid表格控件使用方法2Word文件下载.docx
- 文档编号:20284214
- 上传时间:2023-01-21
- 格式:DOCX
- 页数:15
- 大小:17.51KB
MSHflexGrid表格控件使用方法2Word文件下载.docx
《MSHflexGrid表格控件使用方法2Word文件下载.docx》由会员分享,可在线阅读,更多相关《MSHflexGrid表格控件使用方法2Word文件下载.docx(15页珍藏版)》请在冰豆网上搜索。
PrivateM_PageEnabledAsBoolean
翻页是否有效
PrivateM_ArrowEnabledAsBoolean'
箭头是否有效
PrivateM_EnterActionAsBoolean
回车键的行为.
PrivateM_EditFixAsBoolean
是否可编辑固定行
PrivateM_EnterNextRowAsBoolean'
如果是向右移到了网格的尽头,是否跳转下一行
DimM_PictureAsVB.PictureBox
/事件声明
PrivateWithEventsEv_GridObjAsVBControlExtender'
定义一个针对MSHFLEXGRID的通用事件.
PrivateWithEventsEv_TextAsVB.TextBox'
定义一个TEXT事件
/
/******************属性******************
BindGrid绑定表格,如:
SETBindGrid=Mshflexgrid1.(该属性是最重要的属性.必须首先设置)
PublicPropertyGetBindGrid()AsObject
SetBindGrid=Ev_GridObj
EndProperty
PublicPropertySetBindGrid(ByRefNewGridAsObject)
IfUCase$(TypeName(NewGrid))=UCase$("
MSHFlexGrid"
)Then
SetEv_GridObj=NewGrid'
事件
Else
SetEv_GridObj=Nothing
MsgBox"
该属性只能与MSHFlexGrid绑定!
"
&
Chr$(13)&
"
Cjwa@"
(0668)6422489"
vbOKOnly,"
错误!
EndIf
BindText绑定文本框,如:
SETBindText=ev_text.(该属性是最重要的属性.必须首先设置)
PublicPropertyGetBindText()AsObject
PublicPropertySetBindText(ByRefNewTextAsObject)
IfUCase$(TypeName(NewText))=UCase$("
TextBox"
SetEv_Text=NewText'
Ev_Text.Text="
Ev_Text.Visible=False
SetBindText=Nothing
该属性只能与TextBox绑定!
BindPicture绑定图片框,如:
SETBindPicture=PictureBox1.(该属性是最重要的属性.必须首先设置)
PublicPropertyGetBindPicture()AsObject
SetBindPicture=M_Picture
PublicPropertySetBindPicture(ByRefNewPictureAsObject)
IfUCase$(TypeName(NewPicture))=UCase$("
PictureBox"
SetM_Picture=NewPicture'
M_Picture.Visible=False
SetBindPicture=Nothing
该属性只能与PictureBox绑定!
EditFixed是否可以编辑固定行.
PublicPropertyGetEditFixed()AsBoolean
EditFixed=M_EditFix
PublicPropertyLetEditFixed(ByValNewValueAsBoolean)
M_EditFix=NewValue
EnterAction回车键的行为
PublicPropertyGetEnterAction()AsBoolean
EnterAction=M_EnterAction
PublicPropertyLetEnterAction(ByValNewValueAsBoolean)
M_EnterAction=NewValue
EnterNextRow如果是向右移到了网格的尽头,是否跳转下一行.(EnterAction=True)
PublicPropertyGetEnterNextRow()AsBoolean
EnterNextRow=M_EnterNextRow
PublicPropertyLetEnterNextRow(ByValNewValueAsBoolean)
M_EnterNextRow=NewValue
PageEnabled是否可以翻页
PublicPropertyGetPageEnabled()AsBoolean
PageEnabled=M_PageEnabled
PublicPropertyLetPageEnabled(ByValNewValueAsBoolean)
M_PageEnabled=NewValue
ArrowEnabled是否可以用箭头移动编辑框.
PublicPropertyGetArrowEnabled()AsBoolean
ArrowEnabled=M_ArrowEnabled
PublicPropertyLetArrowEnabled(ByValNewValueAsBoolean)
M_ArrowEnabled=NewValue
DltL输入框左边距微调量
PublicPropertyGetDltL()AsLong
DltL=M_DltL
PublicPropertyLetDltL(ByValNewValueAsLong)
M_DltL=NewValue
DltT输入框顶距边距微调量
PublicPropertyGetDltT()AsLong
DltT=M_DltT
PublicPropertyLetDltT(ByValNewValueAsLong)
M_DltT=NewValue
DltW输入框宽度微调量.
PublicPropertyGetDltW()AsLong
DltW=M_DltW
PublicPropertyLetDltW(ByValNewValueAsLong)
M_DltW=NewValue
DltH输入框高度微调量.
PublicPropertyGetDltH()AsLong
DltH=M_DltH
PublicPropertyLetDltH(ByValNewValueAsLong)
M_DltH=NewValue
AutoSize当网格的行距或列距改变时,是否可以自动调整编辑框的位置.
PublicPropertyGetAutoSize()AsBoolean
AutoSize=M_AutoSize
PublicPropertyLetAutoSize(ByValNewValueAsBoolean)
M_AutoSize=NewValue
***********************方法**************************
/在Scroll事件中
PrivateSubGridScroll()
OnErrorResumeNext
EndSub
/在KeyDown事件中
PrivateSubTextKeyDown(KeyCodeAsInteger)
DimEtxtSelAsLong
EtxtSel=Ev_Text.SelStart
IfEtxtSel=0Then
IfKeyCode=vbKeyLeftThen
CallCodeMove(KeyCode)
ExitSub
IfEtxtSel=Len(Ev_Text.Text)Then
IfKeyCode=vbKeyRightThen
IfKeyCode=vbKeyDownOrKeyCode=vbKeyUpOr_
KeyCode=vbKeyTabOrKeyCode=vbKeyReturnOr_
KeyCode=vbKeyPageUpOrKeyCode=vbKeyPageDown_
OrKeyCode=vbKeyHomeOrKeyCode=vbKeyEndThen
PrivateSubClass_Initialize()
M_AutoSize=False
M_PageEnabled=True
M_ArrowEnabled=True
M_EnterAction=True
M_EditFix=False
M_MoveFlag=True
M_EnterNextRow=True
/受绑定的MSHFLEXGRID中的事件.
PrivateSubEv_GridObj_ObjectEvent(InfoAsEventInfo)
/通用事件接口
SelectCaseUCase$(Info.Name)
CaseUCase$("
MouseDown"
)
CallGridMouseDown
Scroll"
CallGridScroll
GotFocus"
MouseUp"
LeaveCell"
)'
选择改变前发生.
EnterCell"
选择改变后发生.
RowColChange"
最后发生.
EndSelect
/TextChange
/返回参数:
/说明:
编辑框的改变事件.
PrivateSubEv_Text_Change()
DimOleWidthAsLong
DimNewWidthAsLong
IfNot(Ev_GridObjIsNothing)Then
IfEv_GridObj.VisibleAndEv_Text.VisibleAndM_AutoSizeThen
WithM_Picture
.Font.Name=Ev_Text.Font.Name
.Font.Bold=Ev_Text.Font.Bold
.Font.Italic=Ev_Text.Font.Italic
.Font.Underline=Ev_Text.Font.Underline
OleWidth=Ev_GridObj.ColWidth(M_EditCol)
NewWidth=.TextWidth(Ev_Text+"
A"
这里你可以适当调整一下.有一个字符的差别
EndWith
WithEv_GridObj
IfNewWidth>
OleWidthThen
.ColWidth(.Col)=NewWidth
Ev_Text.Width=NewWidth
Ev_GridObj.TextMatrix(M_EditRow,M_EditCol)=Ev_Text
/用键盘事件移动编辑框
PrivateSubCodeMove(KeyCodeAsInteger)
DimFixRowsAsLong,FixColsAsLong
DimVisRowAsLong
M_MoveFlag=False
VisRow=CLng(Ev_GridObj.Height\(Ev_GridObj.RowHeight(Ev_GridObj.Rows-1)+37.5))
IfM_EditFixThen
FixRows=0:
FixCols=0
FixRows=Ev_GridObj.FixedRows:
FixCols=Ev_GridObj.FixedCols
SelectCaseKeyCode
CaseIs=vbKeyUp
IfM_ArrowEnabledThen
IfM_EditRow>
FixRowsThen
M_EditRow=M_EditRow-1
CaseIs=vbKeyDown
IfM_EditRow<
Ev_GridObj.Rows-1Then
M_EditRow=M_EditRow+1
CaseIs=vbKeyLeft
IfM_EditCol>
FixColsThen
M_EditCol=M_EditCol-1
CaseIs=vbKeyRight
IfM_EditCol<
Ev_GridObj.Cols-1Then
M_EditCol=M_EditCol+1
CaseIs=vbKeyTab
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- MSHflexGrid 表格 控件 使用方法