1,如果想把某一列设置成下拉匡中选择,只能写成 grid.colcombolist(1) = \吗?能不能把下拉框中的数据和 recordset 或数组绑定。
答案:grid.colcombolist(1)=grid.buildcombolist(rs!abc) 2,怎样限定第三列可编辑,其他列不可编辑? 答案:
Private Sub fg_BeforeEdit(ByVal Row As Long, ByVal Col As Long, Cancel As Boolean) '*******先将设editable=2 '限定不可编辑列,如有5列 If Col = 0 Then Cancel = True If Col = 1 Then Cancel = True If Col = 2 Then Cancel = True If Col = 4 Then Cancel = True If Col = 5 Then Cancel = True End Sub
3、怎么获得当前单元个的位置,比如某单元个获得焦点,弹出msgbox(\你选的是第4行第5列\Answer:
Private Sub VSFlexGrid1_Click() Dim a, b As Long a = VSFlexGrid1.Row b = VSFlexGrid1.Col
MsgBox \你选的是\行\列\End Sub
4,对vsflexgrid进行编辑的时候,让vsflexgrid的某列只能输入数字? Answer:
Private Sub CheckData(KeyAscii As Integer)
If KeyAscii >= 48 And KeyAscii <= 57 Then Exit Sub '如果是数字退出 If KeyAscii <> 8 Then KeyAscii = 0 End Sub
Private Sub vsflexgrid_KeyPressEdit(ByVal Row As Long, ByVal Col As Long, KeyAscii As Integer)
If col=1 Then '第一列只能输入数字 CheckData KeyAscii End If
End Sub
5,限制某列只能输入数字 Answer:
Private Sub fg_KeyPressEdit(ByVal Row As Long, ByVal Col As Long, KeyAscii As Integer) Dim Numbers As String '允许输入的字符 If fg.Col = 6 Then '第6列
Numbers = \ If InStr(Numbers, Chr(KeyAscii)) = 0 Then KeyAscii = 0 End If End If End Sub
6,如何指定一列的输入格式
VSFlexGrid 控件属性方法一览表VSFlexGrid 控件属性方法一览表(带()为方法) 属性/方法名称 功能 示例语法
AddItem() 增加一行 O.A String[, RowIndex]
Aggregate 返回集合合计(总数,平均,等等) O.A = (A,Row1,Col1,Row2,Col2) Align 对象在窗体上的显示位置 O.A = 0|1|2|3|4
AllowBigSelection 设定列头是否整行或整列选择 O.A = True|False AllowSelection 是否可多单元选择 O.A = True|False AllowUserFreezing 运行时用鼠标冻结行或列 O.A = 0|1|2|3 AllowUserResizing 调整(行/列)大小方式 O.A = 0|1|2|3|4 Appearance 边框平面/凹陷/凸起 O.A = 0|1|2
Archive() 存储或清除一个二进制文件内容 O.A ArcFileName,FileName,0|1|2|3 ArchiveInfo 返回一个二进制文件信息 O.A ArcFileName,0|1|2|3|4,LineIndex AutoReSize 是否自动调整大小 O.A = True|False AutoSearch 设置自动搜索 O.A = 0|1|2 AutoSearchDelay 设置AutoSearch多少秒刷新 O.A = 2
AutoSize() 自动调整列到指定宽度 O.A Col1,Col2,True|False,1000 AutoSizeMode 自动调整适合行列内容 O.A = 0|1
AutoSizeMouse 是否双击列首自动调整适合行列 O.A = True|False BackColor 所有非固定行列的背景色 O.A = Color BackColorAlternate 所有非固定行列的交替行颜色 O.A = Color BackColorBkg 表格背景坐底色 O.A = Color BackColorFixed 固定的行/列背景色 O.A = Color
BackColorFrozen 冻结部分的行列背景色 O.A = Color BackColorSel 单元被选中的背景色 O.A = Color
BindToArray() 绑定数组 O.A ArrayStr,RowDim,ColDim,PageDim,CurrentPage Bookmark 返回ADO Recordset行书签(只读) O.A(Row) BorderStyle 边框粗细样式 O.A = 0|1 BottomRow 返回可见范围的最大行号(只读) O.A
BuildComboList() 将数据库中的内容写入下拉框 O.A(rs, FieldList, KeyField, BackColor) CausesValidation ???目标事件确认 O.A = False|True
Cell 选择部分的相应准则值 O.A(准则, Row1, Col1, Row2, Col2) = 准则值 CellAlignment 设定单元里数据的排列方式 O.A = 0 至 9 CellBackColor 指定单元范围的背景颜色 O.A = Color
CellBorder() 选择单元范围的边界颜色 O.A Color,左,上,右,下,垂直,水平 CellButtonPicture 选择单元范围的按钮图片 O.A = LoadPicture(\CellChecked 选择单元范围的复选框 O.A = 0|1|2 CellFloodColor 选择单元范围的流程颜色 O.A = Color CellFloodPercent 选择单元范围的流程百分比 O.A = 1 至 100 CellFontBold 指定单元范围设为黑体字 O.A = False|True CellFontItalic 指定单元范围设为斜体字 O.A = False|True CellFontName 对象所使用的字体名称 O.A = FontName CellFontSize 对象文字像数大小(默认9pt) O.A = 9 CellFontStrikethru 选择范围是否有删除线 O.A = False|True CellFontUnderline 选择范围是否有下画线 O.A = False|True CellFontWidth 设定单元或指定范围字体的宽度 O.A = 2 CellForeColor 设定单元或指定范围字体的颜色 O.A = Color CellHeight 返回/显示到当前单元高度(只读) O.A CellLeft 返回当前单元的左端位置(只读) O.A
CellPicture 显示在单元或指定范围中的图片 O.A = LoadPicture(\CellPictureAlingment 单元或指定范围图片的显示位置 O.A = 0 至 10 CellTextStyle 设定单元文本的显示形式 O.A = 0|1|2|3|4 CellTop 返回当前单元的顶端位置(只读) O.A CellWidth 返回当前单元的宽度(只读) O.A
Clear() 清除表格内容 O.A([0|1|2],[0|1|2|3]) ClientHeight 返回客户可见范围高度 O.A ClientWidth 返回客户可见范围宽度 O.A Clip 设置选择范围的内容 O.A = Text
ClipSeparators ???
Col 设置激活单元的列号 O.A = 2
ColAlignment 列对齐排列方式 O.A(Col) = 0 至 9
ColComboList 向下拉框写入管道字符 O.A(Col) = \ColData 设置用户定义的长整形数据 O.A(Col) = UserLong ColDataType 列数据类型 O.A(Col)=0至14到20(&H14),30(&H1E),31(&H1F)
ColEditMask 列编辑套用格式字符串 O.A(Col) = 指定的格式如:###### ColFormat 格式化显示列 O.A(Col) = \ColHidden 是否隐藏指定列 O.A(Col) = True|False ColImageList 设置图像列表句柄到列
ColIndent 缩进指定列 O.A Col= 100 ColIndex 返回列索引(只读) O.A Col ColIsVisible 返回列是否可见(只读) O.A Col ColKey 设置列钥匙 O.A(Col) = KeyStr ColPos 返回列距左边宽度(只读) O.A Col ColPosition 移动列的位置 O.A(Col) = ReCol Cols 返回/设置总列数 O.A = 2 ColSel 返回/设置最后选择的列 O.A = 3 ColSort 设置列种类 O.A(Col) = 0 至 10 ColWidth 返回/设置指定列宽 O.A(Col) = 100 ColWidthMax 最大列宽 O.A(Col) = 5000 ColWidthMin 最小列宽 O.A(Col) = 100 ComboCount 取得Combo下拉按钮总数(只读) O.A ComboData Combo下拉按钮数据(只读) O.A ComboIndex Combo下拉按钮索引 O.A = 1 ComboItem Combo下拉按钮项目(只读) O.A ComboList 向下拉框写入管道字符内容 O.A = \ComboSearch Combo下拉按钮搜寻方式 O.A = 0|1|2|3 Container 返回/设置对象的容器 O.A.Caption = \DataBindings 返回数据装入数(只读) O.A
DataMember 返回/设置数据描述成员 O.A = DataStr DataMode 设置数据链接状态 O.A = 0|1|2|3|4 DataRefresh() 刷新数据源 O.A
DataSource 设置数据源 Set O.A = DataDim
Drag() 拖放 O.A [0|1|2]
DragIcon 拖放图标 O.A = LoadPicture(\DragMode 拖放方式 O.A = 0|1
DragRow() 拖放行(本示例在MouseDown过程) O.A O.RowSel Editable 设置表格是否可编辑修改 O.A = 0|1|2 EditCell() 当移动到当前单元时自动选择 O.A
EditMask 当编辑时只能使用指定值 O.A = StrValue EditMaxLength 所有单元限制字节大小 O.A = 2 EditSelLength 编辑时选择长度 O.A = 5
EditSelStart 移动到单元时的光标位置 O.A = 0(或者Len(vsg.text)) EditSelText 编辑选择处放文本 O.A = \ EditText 编辑文本 O.A = \EditWindow 返回编辑窗口(只读) O.A Ellipsis 超宽字符加省略号 O.A = 0|1|2 Enabled 对象是否激活可用 O.A = False|True ExplorerBar 单击列头的选择、拖动或排序样式 O.A = 0 至 15 ExtendLastCol 是否扩充最后的列到适合宽度 O.A = False|True FillStyle 是否改变当前范围的内容或格式 O.A = 0|1
FindRow 查找符和条件返回的行(只读) O.A FindStr,[Row],[Col],[敏感],[精度]) FinishEditing() 完成编辑的 O.A = False|True FixedAlignment 固定列的对齐方式 O.A(Col) = 0 至 9 FixedCols 固定几列 O.A = 1 FixedRows 固定几行 O.A = 1 FlexDataSource 流动数据源 O.A = rsDate FloodColor 设置流程颜色 O.A = Color
FocusRect 单元的选择虚框样式类型 O.A = 0|1|2|3|4|5 Font 设定字体 O.A = FontName FontBold 设定字体粗体 O.A = False|True FontItalic 设定字体斜体 O.A = False|True FontName 设定字体名称 O.A = FontName FontSize 设定字体大小 O.A = 10
FontStrikethru 设定字体删除线 O.A = False|True FontUnderline 设定字体下划线 O.A = False|True FontWidth 设定字体的宽度(非间距) O.A = 2 ForeColor 设定字体前景颜色 O.A = Color