igrid表格控件的简单测试
By
admin
at 2020-02-23 • 0人收藏 • 2573人看过
之前已经封装过flexcell的表格控件了, 最近瞎逛, 发现这个igrid也挺有特色的,
igrid的特色:
1, igrid支持树形表格模式, 当然flexcell也支持, 不过它要你自己写node格式解析
2, igrid的分组功能很强大
3, igrid的排序功能很快,支持各个分组排序
下面是aardio对igrid控件的测试示例:
import win.ui; /*DSG{{*/ var winform = win.form(text="aardio form";right=759;bottom=469) winform.add( button={cls="button";text="Button";left=10;top=423;right=214;bottom=469;z=2}; button2={cls="button";text="Button";left=556;top=424;right=760;bottom=470;z=3}; static={cls="static";text="Static";left=0;top=0;right=760;bottom=396;transparent=1;z=1} ) /*}}*/ var grid = winform.static.createEmbed("iGrid400_10Tec.iGrid"); var iGrid1 = grid._object; import console console.open() winform.button.oncommand = function(id,event){ iGrid1.Clear(true) iGrid1.BeginUpdate() iGrid1.ColCount = 3 iGrid1.setColWidth(1,200) iGrid1.TreeCol = 1 iGrid1.AddRow(); iGrid1.setCellValue(iGrid1.RowCount, 1,"Root-1"); iGrid1.AddRow(,,,,,1); iGrid1.setCellValue(iGrid1.RowCount, 1,"Child-1.1"); iGrid1.AddRow(,,,,,2); iGrid1.setCellValue(iGrid1.RowCount, 1,"Child-1.1.1"); iGrid1.AddRow(,,,,,2); iGrid1.setCellValue(iGrid1.RowCount, 1,"Child-1.1.2"); iGrid1.EndUpdate() } winform.button2.oncommand = function(id,event){ var CATEGORY_APPEARANCE = "Appearance" var CATEGORY_MISC = "Misc" var CATEGORY_BEHAVIOR = "Behavior" var CATEGORY_POSITION = "Position" var False = false var True = true var igAlignVCenter = 1 var igCellCombo = 1 var igComboBtnFlat =8 var igTextWordBreak =16 iGrid1.Clear(true) iGrid1.BeginUpdate() iGrid1.Header.Visible = False iGrid1.FocusRect = False iGrid1.GridLineColor =0 iGrid1.setGridLines =3 iGrid1.DefaultRowHeight = 20 iGrid1.ShowControlsInAllCells = True iGrid1.UseXPStyles = False iGrid1.AddCol("group",,100,,,,,False); iGrid1.AddCol("prop").eAlignV = igAlignVCenter iGrid1.AddCol("value",,100).eAlignV = igAlignVCenter iGrid1.setColKey(iGrid1.RowTextCol,"category" ) iGrid1.ColDefaultCell("category").eAlignV = igAlignVCenter iGrid1.AddRow() iGrid1.setCellValue(iGrid1.RowCount, "prop","(Name)") iGrid1.setCellValue(iGrid1.RowCount, "value","value") iGrid1.setCellValue(iGrid1.RowCount, "category",CATEGORY_MISC) iGrid1.AddRow() iGrid1.setCellValue(iGrid1.RowCount, "prop","Alignment") var Combos = iGrid1.Combos.Add("Justify") Combos.AddItem("0 - Left Justify", 0) Combos.AddItem("1 - Right Justify", 1) Combos.AddItem("2 - Center", 2) iGrid1.setCellType(iGrid1.RowCount, "value",igCellCombo) iGrid1.setCellTypeFlags(iGrid1.RowCount, "value",igComboBtnFlat) iGrid1.setCellCtrlKey(iGrid1.RowCount, "value","Justify") iGrid1.setCellValue(iGrid1.RowCount, "value",1) iGrid1.setCellValue(iGrid1.RowCount, "category",CATEGORY_MISC) iGrid1.AddRow() iGrid1.setCellValue(iGrid1.RowCount, "prop","Appearance") var Combos = iGrid1.Combos.Add("Appearance") Combos.AddItem("0 - Flat", 0) Combos.AddItem("1 - 3D", 1) iGrid1.setCellType(iGrid1.RowCount, "value",igCellCombo) iGrid1.setCellTypeFlags(iGrid1.RowCount, "value",igComboBtnFlat) iGrid1.setCellCtrlKey(iGrid1.RowCount, "value","Appearance") iGrid1.setCellValue(iGrid1.RowCount, "value","0 - Flat") iGrid1.setCellValue(iGrid1.RowCount, "category",CATEGORY_APPEARANCE) iGrid1.AddRow() iGrid1.setCellValue(iGrid1.RowCount, "prop","AutoSize") var Combos = iGrid1.Combos.Add("True/False") Combos.AddItem("True", True) Combos.AddItem("False", False) iGrid1.setCellType(iGrid1.RowCount, "value",igCellCombo) iGrid1.setCellTypeFlags(iGrid1.RowCount, "value",igComboBtnFlat) iGrid1.setCellCtrlKey(iGrid1.RowCount, "value","True/False") iGrid1.setCellValue(iGrid1.RowCount, "value","True") iGrid1.setCellValue(iGrid1.RowCount, "category",CATEGORY_POSITION) iGrid1.AutoWidthCol("prop") iGrid1.EndUpdate() } winform.show(); win.loopMessage();
以上测试使用的是igrid4.0版本破解版和帮组文档
使用上面的示例, 首先你要先注册解压后的两个ocx!
有能力的人, 请支持正版!
6 个回复 | 最后更新于 5 天前
3,测试添加下拉框图标
import iGrid400; var iGrid1 = iGrid400(mainForm.static); var imglistobj = com.CreateObject("vbalIml220_10Tec.vbalImageList"); //设定图标的宽度和高度(必须) imglistobj.ImageHeight = 15 imglistobj.ImageWidth = 15 imglistobj.ColorDepth = 32 imglistobj.MaskColor = 0 //创建之后才能添加图片 imglistobj.Create() //从文件中添加(参数:文件路径,文件类型0=BITMAP/1=ICO/2=CURSOR,设定引用名) imglistobj.AddFromFile("C:\Program Files\10Tec\ActiveX\iGrid 4.0\Demo_Main\Graphics\PropEditor\Colors_NotTransparent\BLACK.bmp",0,"black"); imglistobj.AddFromFile("C:\Program Files\10Tec\ActiveX\iGrid 4.0\Demo_Main\Graphics\PropEditor\Colors_NotTransparent\RED.bmp",0,"red"); imglistobj.AddFromFile("C:\Program Files\10Tec\ActiveX\iGrid 4.0\Demo_Main\Graphics\PropEditor\Colors_NotTransparent\WHITE.bmp",0,"white"); imglistobj.AddFromFile("C:\Program Files\10Tec\ActiveX\iGrid 4.0\Demo_Main\Graphics\PropEditor\Colors_NotTransparent\BLUE.bmp",0,"blue"); //为表格设置图标列表 iGrid1.SetImageList(imglistobj) //定义名字为colors的下拉框 var Combos = iGrid1.Combos.Add("Colors") //为下拉框设置图标 Combos.SetImageList(imglistobj) //添加下拉框项目(参数:项目名,该项所代表值,图标索引) Combos.AddItem("black",0,imglistobj.ItemIndex("black")) Combos.AddItem("red", 1,imglistobj.ItemIndex("red")) Combos.AddItem("blue", 2,imglistobj.ItemIndex("blue")) //设置单元格类型(参数:行,列,下拉框类型) iGrid1.setCellType(5, 3,1) //1=igCellCombo 类型 iGrid1.setCellTypeFlags(5, 3,8) //8=igComboBtnFlat 样式 //设置单元格引用名字为colors的下拉框 iGrid1.setCellCtrlKey(5, 3,"Colors") //设置单元格值=2(此处2=blue),即默认显示为blue项 iGrid1.setCellValue(5, 3,2)
封装了一点, 暂时不写这个igrid库了, 还有其他是要做.
智能提示也没写呢, 很多函数也没有开始封装,嗯, 先这样
第一版 iGrid400.aardio 用户库
//iGrid表格库 import com.activeX; import fsys; class iGrid400{ ctor( winform,row=11,col=5 ){ winform.onEraseBkgnd = function(hwnd,message,wParam,lParam){ return 0;//禁止擦除背景 }; this = winform.createEmbed("iGrid400_10Tec.iGrid"); this._object.GridLineColor = 0x4C7449; //this._object.BackColorOddRows = 0xC7E2C8 //this._object.BackColorEvenRows = 0xFFEACF; this._object.StoreInitRowNumbers = 3; this._object.DefaultRowHeight = 19; this._object.setGridLines = 1; this._object.ColCount = col; this._object.RowCount = row; ..com.Connect(this._object,{ DblClick = function(Button,Shift,x,y,lRow,lCol,eAction){ return this._object.DblClick(Button,Shift,x,y,lRow,lCol,eAction); }; MouseDown = function(Button,Shift,x,y,lRow,lCol,eCellPart,bDoDefault){ return this._object.MouseDown(Button,Shift,x,y,lRow,lCol,eCellPart,bDoDefault); }; CellSelectionChange = function(lRow,lCol,bSelected){ return this._object.CellSelectionChange(lRow,lCol,bSelected); }; BeforeCommitEdit = function(lRow,lCol,eResult,sNewText,vNewValue,lConvErr,bCanProceedEditing){ return this._object.BeforeCommitEdit(lRow,lCol,eResult,sNewText,vNewValue,lConvErr,bCanProceedEditing); }; TextEditChange = function(lRow,lCol){ return this._object.TextEditChange(lRow,lCol); }; AfterCommitEdit = function(lRow,lCol){ return this._object.AfterCommitEdit(lRow,lCol); }; RequestEdit = function(lRow,lCol,iKeyAscii,bCancel,sText,lMaxLength,eTextEditOpt){ return this._object.RequestEdit(lRow,lCol,iKeyAscii,bCancel,sText,lMaxLength,eTextEditOpt); }; CancelEdit = function(lRow,lCol){ return this._object.CancelEdit(lRow,lCol); }; CancelEdit = function(lRow,lCol){ return this._object.CancelEdit(lRow,lCol); }; ColHeaderClick = function(lCol,bDoDefault,Shift,x,y){ return this._object.ColHeaderClick(lCol,bDoDefault,Shift,x,y); }; CustomDrawCell = function(lRow,lCol,hdc,lLeft,lTop,lRight,lBottom,bSelected){ return this._object.CustomDrawCell(lRow,lCol,hdc,lLeft,lTop,lRight,lBottom,bSelected); }; }); return this._object; }; @_metaProperty; } namespace iGrid400{ }
使用示例: mainform.aardio
import win.ui; /*DSG{{*/ mainForm = win.form(text="igrid演示";right=679;bottom=442) mainForm.add( static={cls="static";left=0;top=0;right=680;bottom=357;bgcolor=15780518;db=1;dl=1;dr=1;dt=1;z=1} ) /*}}*/ import console console.open() import iGrid400; var iGrid1 = iGrid400(mainForm.static); iGrid1.ShowControlsInAllCells = true var imglistobj = com.CreateObject("vbalIml220_10Tec.vbalImageList"); //设定图标的宽度和高度(必须) imglistobj.ImageHeight = 15 imglistobj.ImageWidth = 15 imglistobj.ColorDepth = 32 imglistobj.MaskColor = 0 //创建之后才能添加图片 imglistobj.Create() //从文件中添加(参数:文件路径,文件类型0=BITMAP/1=ICO/2=CURSOR,设定引用名) imglistobj.AddFromFile("C:\Program Files\10Tec\ActiveX\iGrid 4.0\Demo_Main\Graphics\PropEditor\Colors_NotTransparent\BLACK.bmp",0,"black"); imglistobj.AddFromFile("C:\Program Files\10Tec\ActiveX\iGrid 4.0\Demo_Main\Graphics\PropEditor\Colors_NotTransparent\RED.bmp",0,"red"); imglistobj.AddFromFile("C:\Program Files\10Tec\ActiveX\iGrid 4.0\Demo_Main\Graphics\PropEditor\Colors_NotTransparent\WHITE.bmp",0,"white"); imglistobj.AddFromFile("C:\Program Files\10Tec\ActiveX\iGrid 4.0\Demo_Main\Graphics\PropEditor\Colors_NotTransparent\BLUE.bmp",0,"blue"); //为表格设置图标列表 iGrid1.SetImageList(imglistobj) //定义名字为colors的下拉框 var Combos = iGrid1.Combos.Add("Colors") //为下拉框设置图标 Combos.SetImageList(imglistobj) //添加下拉框项目(参数:项目名,该项所代表值,图标索引) Combos.AddItem("black",0,imglistobj.ItemIndex("black")) Combos.AddItem("red", 1,imglistobj.ItemIndex("red")) Combos.AddItem("blue", 2,imglistobj.ItemIndex("blue")) //设置单元格类型(参数:行,列,下拉框类型) iGrid1.setCellType(5, 3,1) //1=igCellCombo 类型 iGrid1.setCellTypeFlags(5, 3,8) //8=igComboBtnFlat 样式 //设置单元格引用名字为colors的下拉框 iGrid1.setCellCtrlKey(5, 3,"Colors") //设置单元格值=2(此处2=blue),即默认显示为blue项 iGrid1.setCellValue(5, 3,2) iGrid1.setCellType(5, 4,3)//igCellCustomDraw iGrid1.DblClick = function(Button,Shift,x,y,lRow,lCol,eAction){ console.log("DblClick",Button,Shift,x,y,lRow,lCol,eAction) } iGrid1.CellSelectionChange = function(lRow,lCol,bSelected){ console.log("CellSelectionChange",lRow,lCol,bSelected) } iGrid1.AfterCommitEdit = function(lRow,lCol){ console.log("AfterCommitEdit",lRow,lCol) } /** //暂时还没弄好自绘 import gdip; iGrid1.CustomDrawCell = function(lRow,lCol,hdc,lLeft,lTop,lRight,lBottom,bSelected){ //console.log("CustomDrawCell",lRow,lCol,hdc,lLeft,lTop,lRight,lBottom,bSelected) //图形对象graphics(可以看作是画板) var graphics = gdip.graphics(hdc) //加上抗锯齿功能 graphics.smoothingMode = 4/*_GdipSmoothingModeAntiAlias*/; //创建渐变刷子 var brush = gdip.lineBrush( ::POINTF(10,10)/*渐变起始坐标*/, ::POINTF(100,100) /*渐变终止坐标*/ , 0xFFFFFF00/*起始颜色*/, 0xFF00FFFF/*结束颜色*/ ) graphics.fillRectangle(brush,lLeft,lTop,100,lBottom-lTop); brush.delete(); graphics.delete(); } **/ mainForm.show(); return win.loopMessage();
登录后方可回帖
2. 测试了下单元格中增加图标
测过程中发现 , igrid中有些方法和属性并不能有效果, 可能是这些方法aar不支持(或者是我使用的方法不对 ::>_<:: ) , 比如上面注释掉的那些属性都是没效果不支持的.