使用 IntraWeb (20) - 基本控件之 TIWGrid    


TIWGrid 最终通过 Html Table 呈现; 其每个 Cell 都是一个 TIWGridCell 对象, Cell 对象的 Control 属性非常好, 可以非常方便地嵌入其他控件.



TIWGrid 所在单元及继承链:
IWCompGrids.TIWGrid < TIWCustomGrid < TIWCustomControl < TIWBaseHTMLControl < TIWBaseControl < TIWVCLBaseControl < TControl < TComponent < TPersistent < TObject

主要成员:


property Cell[const ARow: Integer, const AColumn: Integer]: TIWGridCell //读取单元格对象property RowCount: Integer    //行数property ColumnCount: Integer //列数property ShowInvisibleRows: Boolean  //是否隐藏空行property HiddenColumns: TStringList  //隐藏指定列, 譬如: IWGrid1.HiddenColumns.CommaText := '0,2'; 是隐藏第 1、3 列property ShowEmptyCells: Boolean     //是否显示空的单元格; 好像存在点问题property BGColor: TIWColor           //property BorderColors: TIWGridBorderColors //边框色分为: 主色、暗色、亮色(Color、Dark、Light)property BorderSize: Integer               //线宽, 对应 Table 的 Border 属性property BorderStyle: TIWGridBorderStyle   //它对应 Table 的 frame 属性(边框相关); 使用具体的属性值需要 uses IWCompGridCommonproperty Caption: TCaption     //property CellPadding: Integer  //单元格内边距property CellSpacing: Integer  //单元格间距property Font: TIWFont         //如果各单元格字体一直, 可以在这里一起指定property FrameBuffer: Integer  //?property Lines: TIWGridLines   //对应 Table 的 Rules 属性: tlAll、tlNone、tlRows、tlColsproperty Summary: string       //对应 Table 的 summary 属性property UseFrame: Boolean     //是否使用框架, 在需要时它会给出滚动条property UseSize: Boolean      //是否使用设计时的大小; 好像只对宽度有用property CurrentRow: Integer         //如果 ScrollToCurrentRow = True, 可通过 CurrentRow 让指定行立即可见 property ScrollToCurrentRow: Boolean //参见 CurrentRowproperty CellRenderOptions: TIWCellRenderOptions //集合选项, 决定哪些 Cell 相关的设置会被使用: [crAlign, crBGcolor, crCellPadding, crStyle, crValign]property OnCellClick: TIWOnCellClick   //如果 TIWGridCell.Clickable = True; 单元格中的文本就会变成链接, 以响应该事件property OnRenderCell: TIWOnRenderCell //同 TStringGrid 中的 OnDrawCell, 可以在此事件中个性化单元格property OnGetCellRenderOptions: TIWGetCellRenderOptionsEvent //可以从这里设置某些单元格的 CellRenderOptions 属性procedure Clear //function CellExists(const ARow: Integer; const AColumn: Integer): Boolean //判断参数指定的单元格是否有效(譬如超界了)procedure DeleteColumn(const AColumn: Integer)  //删除列procedure DeleteRow(const ARow: Integer)        //删除行


TIWGridCell:


{IWCompGrids.TIWGridCell < TCollectionItem < TPersistent < TObject}property Grid: TIWCustomGridproperty DoRefreshControl: Booleanproperty Clickable: Boolean  //property Alignment: TAlignment  //property VAlign: TIWVerticalAlignment //property BGColor: TIWColorproperty Control: TIWCustomControl  //嵌入其他控件property DoSubmitValidation: Booleanproperty Font: TIWFontproperty Header: Booleanproperty Height: stringproperty Hint: stringproperty ShowHint: Booleanproperty Tag: TObjectproperty Text: string  //property UnlinkedText: stringproperty Visible: Booleanproperty Width: stringproperty Wrap: Boolean    //property RawText: Boolean //property Css: stringproperty Collection: TCollectionproperty ID: Integerproperty Index: Integerproperty DisplayName: string


测试:


procedure TIWForm1.IWAppFormCreate(Sender: TObject);var  i,j: Integer;begin  IWGrid1.RowCount := 5;  IWGrid1.ColumnCount := 3;  IWGrid1.Caption := 'Test Table';  IWGrid1.BGColor := $d0d0d0;  IWGrid1.CellPadding := 8;  IWGrid1.Font.Size := 12;  IWGrid1.Lines := tlCols;  for i := 0 to IWGrid1.RowCount - 1 do    for j := 0 to IWGrid1.ColumnCount - 1 do    begin      IWGrid1.Cell[i,j].Text := Format('%d, %d', [i, j]);      IWGrid1.Cell[i,j].Alignment := taCenter;//      IWGrid1.Cell[i,j].VAlign := vaMiddle;      IWGrid1.Cell[i,j].Clickable := True;      if Odd(i) then IWGrid1.Cell[i,j].BGColor := $f0f0f0;    end;  LinkColor := $0000FF;  IWGrid1.UseSize := True;end;{OnCellClick}procedure TIWForm1.IWGrid1CellClick(ASender: TObject; const ARow, AColumn: Integer);begin  WebApplication.ShowMessage(IWGrid1.Cell[ARow, AColumn].Text);end;


效果图:




©著作权归作者所有:来自51CTO博客作者JLee79的原创作品,如需转载,请注明出处,否则将追究法律责任

更多相关文章

  1. Delphi 正则表达式语法(10): 选项
  2. Delphi 正则表达式之TPerlRegEx 类的属性与方法(7): Split 函数
  3. Delphi 正则表达式之TPerlRegEx 类的属性与方法(1): 查找
  4. CSS样式规则-CSS结构的特点
  5. css详解background八大属性及其含义
  6. css详解position五种属性用法及其含义
  7. Visual Studio 2019 C++使用log4cplus
  8. 网站加载页面(HTML+CSS+JS,简易版)
  9. 210406 类数组 获取遍历DOM元素 向元素添加文本 获取元素的自定

随机推荐

  1. Android的Recovery中font_10x10.h字库文
  2. Android上的Adobe AIR应用程序运行环境发
  3. android7.0适配
  4. Android之动画Animation的使用
  5. Android selector背景选择器 用法汇总
  6. 学习Android studio 个人总结小经验
  7. Android有用代码(一)
  8. Learning Android(第一季)01-Android平台一
  9. Android入门教程 sharedpreferences的用
  10. Android(安卓)HAL 开发 (1)