⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vfp例子说明.txt

📁 Linux源码完全注释
💻 TXT
字号:
1、首先注册coolgrid.ocx控件。
2、把控件拖到窗体上,命名为olecontrol1
3、双击控件在Init过程输入以下代码(复制粘贴以下代码即可):
thisform.olecontrol1.formatstring=" |^编号|<客户名称|<商品名称|>单价|>数量|^单位|>总金额|^审核|^日期|^时间|<链接"
thisform.olecontrol1.rows=10
thisform.olecontrol1.colwidth(1)=500
thisform.olecontrol1.colwidth(2)=1500
thisform.olecontrol1.colwidth(3)=1500
thisform.olecontrol1.colwidth(4)=1000
thisform.olecontrol1.colwidth(5)=800
thisform.olecontrol1.colwidth(6)=500
thisform.olecontrol1.colwidth(7)=1500
thisform.olecontrol1.colwidth(8)=800
thisform.olecontrol1.colwidth(9)=1800
thisform.olecontrol1.colwidth(10)=0
thisform.olecontrol1.colwidth(11)=2000
thisform.olecontrol1.ColType( 2,2)&&eCombobox &&指定此列为ComboBox
thisform.olecontrol1.EditEnable = .T.  &&表格可编缉
&&thisform.olecontrol1.EditTextLenght = 50
thisform.olecontrol1.ColType (2, 2) &&指定此列为ComboBox
thisform.olecontrol1.ColType (6, 2) &&指定此列为ComboBox
thisform.olecontrol1.ColType (8, 1) &&指定此列为CheckBox
thisform.olecontrol1.ColType (9, 3) &&指定此列为日期
thisform.olecontrol1.ColType (11, 4) &&指定此列为超级链接
thisform.olecontrol1.CalendarCheckBox(9) = .T. &&给日期格增加一个复选框,这样才能够保持这一格空白
thisform.olecontrol1.CalendarFormat(9) = 3 &&自定义日期格式
thisform.olecontrol1.CalendarCustomFormat(9) = "yyyy年MM月dd日" &&日期格式字符串
thisform.olecontrol1.SortOnHeaderClick(.T., 1) &&点击表头时升序排序

thisform.olecontrol1.ColType (3, 5) &&指定此列为按钮
        
thisform.olecontrol1.ComboBoxAddItem(2, "A列表框内容1") &&为第二列的ComboBox添加数据
thisform.olecontrol1.ComboBoxItemData(2, 0) = 11111
thisform.olecontrol1.ComboBoxAddItem(2, "B列表框内容2")
thisform.olecontrol1.ComboBoxItemData(2, 1) = 22222
thisform.olecontrol1.ComboBoxAddItem(2, "2列表框内容3")
thisform.olecontrol1.ComboBoxItemData(2, 2) = 33333
thisform.olecontrol1.ComboBoxAddItem (2, "C列表框内容4")
thisform.olecontrol1.ComboBoxItemData(2, 3) = 44444
thisform.olecontrol1.ComboBoxAddItem (2, "其他选择...")
thisform.olecontrol1.ComboBoxItemData(2, 4) = 999
        
thisform.olecontrol1.ComboBoxAddItem (6, "个") &&为第三列的ComboBox添加数据
thisform.olecontrol1.ComboBoxAddItem (6, "箱")
thisform.olecontrol1.ComboBoxAddItem (6, "斤")
thisform.olecontrol1.ComboBoxAddItem (6, "Kg")
thisform.olecontrol1.ComboBoxAddItem (6, "台")
        
thisform.olecontrol1.AutoAddCol = 1 &&第一列自动增加
&&thisform.olecontrol1.LockColAdd 3 &&锁定第三列
thisform.olecontrol1.LockColAdd(7) &&锁定第6列
thisform.olecontrol1.OnlyNum (5)  &&第五列只能输入数字
thisform.olecontrol1.beCur (4) &&第四列只能输入金额
thisform.olecontrol1.beCur (7) &&第四列只能输入金额
thisform.olecontrol1.preCur ("¥") &&金额的前缀
thisform.olecontrol1.AutoCalc1 = 4 &&自动计算因子一列
thisform.olecontrol1.AutoCalc2 = 5 &&自动计算因子二列
thisform.olecontrol1.AutoCalcOPE = "*" &&自动计算运算符
thisform.olecontrol1.AutoCalcRES = 7 &&自动计算结果列
thisform.olecontrol1.AutoGrow = .T. &&自动增长
thisform.olecontrol1.NullLine = .F. &&不允许添加空行
thisform.olecontrol1.cgChecked(2, 8) = .T. &&此单元格设为已选
        &&添加数据
thisform.olecontrol1.TextMatrix(1, 2) = "恒驰网络公司"
thisform.olecontrol1.TextMatrix(2, 2) = "山东淄博"
thisform.olecontrol1.TextMatrix(3, 2) = "红色十月"
thisform.olecontrol1.TextMatrix(4, 2) = "中华人民共和国"
thisform.olecontrol1.TextMatrix(5, 2) = "http://hinfo.cn"
thisform.olecontrol1.TextMatrix(6, 2) = "coolGrid"
thisform.olecontrol1.TextMatrix(7, 2) = "数据网络开发"
thisform.olecontrol1.TextMatrix(8, 2) = "NetSpider"
        
thisform.olecontrol1.TextMatrix(1, 3) = "联想笔记本电脑"
thisform.olecontrol1.TextMatrix(2, 3) = "绿皮冬瓜"
thisform.olecontrol1.TextMatrix(3, 3) = "摄影机镜头"
thisform.olecontrol1.TextMatrix(4, 3) = "哈密瓜"
thisform.olecontrol1.TextMatrix(5, 3) = "羊肉"
thisform.olecontrol1.TextMatrix(6, 3) = "青岛啤酒"
thisform.olecontrol1.TextMatrix(7, 3) = "数码相机"
thisform.olecontrol1.TextMatrix(8, 3) = "Cell Phone"
        
thisform.olecontrol1.TextMatrix(1, 4) = "¥10.00"
thisform.olecontrol1.TextMatrix(2, 4) = "¥30.00"
thisform.olecontrol1.TextMatrix(3, 4) = "¥555.00"
thisform.olecontrol1.TextMatrix(4, 4) = "¥5.00"
thisform.olecontrol1.TextMatrix(5, 4) = "¥12.00"
thisform.olecontrol1.TextMatrix(6, 4) = "¥130.00"
thisform.olecontrol1.TextMatrix(7, 4) = "¥4,567.00"
thisform.olecontrol1.TextMatrix(8, 4) = "¥218.00"
        
thisform.olecontrol1.TextMatrix(1, 5) = "100"
thisform.olecontrol1.TextMatrix(2, 5) = "20"
thisform.olecontrol1.TextMatrix(3, 5) = "30.45"
thisform.olecontrol1.TextMatrix(4, 5) = "100"
thisform.olecontrol1.TextMatrix(5, 5) = "12.04"
thisform.olecontrol1.TextMatrix(6, 5) = "500"
thisform.olecontrol1.TextMatrix(7, 5) = "1"
thisform.olecontrol1.TextMatrix(8, 5) = "12"
        
thisform.olecontrol1.TextMatrix(1, 6) = "台"
thisform.olecontrol1.TextMatrix(2, 6) = "个"
thisform.olecontrol1.TextMatrix(3, 6) = "个"
thisform.olecontrol1.TextMatrix(4, 6) = "Kg"
thisform.olecontrol1.TextMatrix(5, 6) = "斤"
thisform.olecontrol1.TextMatrix(6, 6) = "箱"
thisform.olecontrol1.TextMatrix(7, 6) = "台"
thisform.olecontrol1.TextMatrix(8, 6) = "台"
thisform.olecontrol1.TextMatrix(1, 11) = "http://hinfo.cn"
4、在btnClick事件中输入以下代码:
*** ActiveX 控件事件 ***
LPARAMETERS rowindex, colindex
messagebox(thisform.olecontrol1.TextMatrix(RowIndex, ColIndex),48)
5、在窗体上放置7个按钮,Caption分别为:“添加”、“删除”、“清空”、“画图”、“插入”、“删除第5行”、“排序第3列”。代码分别如下:
添加:thisform.olecontrol1.additem("")
删除:thisform.olecontrol1.RemoveItem
清空:thisform.olecontrol1.clear
画图:
&&这里举一个很简单的例子,说明一下在表格中画图的功能,你可以很方便的做出图文并貌地表格来。
thisform.olecontrol1.Row = 9
thisform.olecontrol1.Col = 7
thisform.olecontrol1.CellPictureAlignment = 4
thisform.olecontrol1.CellPicture = LoadPicture("..\66.gif")
插入:thisform.olecontrol1.AddItem(chr(9) + Str(5) + chr(9) + "123" + chr(9) + "000", 6)
删除第5行:thisform.olecontrol1.RemoveItem(5)
排序第3列:thisform.olecontrol1.sortOnCol(3,2)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -