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

📄 使用说明.txt

📁 delphi制作表格的控件
💻 TXT
📖 第 1 页 / 共 2 页
字号:
安装时请按照以下序列:
  
  Component->Install Packges-> <Add> 选择Discovery.bpl
  Options->Library->Search Path 中加入搜索路径。


EasyGrid 使用说明:

  一、单元格属性;
      // **************************************************
      // EasyGrid 的 Cells[i,j] 属性不同于 StringGrid。
      // StringGrid 的 Cells 仅仅是一个字符串,而 EasyGrid
      // 的 Cells 可以存储丰富的数据类型。
      //
      // 使用范例:
      //     EasyGrid1.Cells[1,2].Color := clRed;
      // 将第一列第二行的一个单元格背景置为红色。
      //
      // !!! 需要注意的是:
      //     上述语法不会导致网格自动刷新(即结果不会马上反映),因为上述语法
      // 实际上是对内存地址直接写入,这样做的好处在于,如果大批量写入数据,这
      // 是最快的方法,不会出现慢镜头式的现象。
      //     用 EasyGrid1.Colors[1,2] := clRed; 可以实现同样效果并实时刷新,
      // 但大批量写入数据时速度较慢。
      //     对大批量写入数据的处理一般需要使用 AutoUpdate 属性:
      //       EasyGrid1.AutoUpdate := False;
      //       ... 大批量写入数据
      //       EasyGrid1.AutoUpdate := True;
      //     AutoUpdate 属性的使用类似于一个与 DbGrid 关联的 DataSource 控件,
      // 当 DataSource 内容改变时,需要把 DataSource 的 Enabled 属性置为 False。
      // 以防止 DbGrid 出现慢镜头式的现象。
      // **************************************************

      // **************************************************
      // 单元格属性说明如下:
      TCellInfo = record
        DataStyle : TDataStyle;  // 数据格式
          // 可用数据格式为:
          // TDataStyle = (dsText,dsNumber,dsDate,dsTime,dsFormula);
        AlignMode : TAlignMode;  // 对齐方式
          // 可用对齐方式为:
          // TAlignMode = (taTopLeft, taTop, taTopRight,
          //               taLeft, taCenter, taRight,
          //               taBottomLeft, taBottom, taBottomRight);
        ReadOnly : Boolean;      // 单元格是否可编辑
        AutoWordBreak : Boolean; // 文字自动折行
        ShowForeText : Boolean;  // 显示控制(Default True)
          // 说明:每个单元格允许存放两个字符串:
          //       ForeText 与 BackText
          // ShowForeText 属性用于指定该网格显示哪一个字符串
        DrawTop : Boolean;       // 画顶线
        DrawLeft : Boolean;      // 画左线
        DrawBottom : Boolean;    // 画底线
        DrawRight : Boolean;     // 画右线

        // 下面七个属性对于 DataStyle 为 dsNumber (数值型)的网格有效
        AllowNegative : Boolean; // 是否允许输入负数
        TrailingZero : Boolean;  // 是否在小数后面补 0
        ZeroNull : Boolean;      // 输入数值 0 时是否当作空串处理
        ThousandSep : Boolean;   // 是否有千分号
        MaxLength : Integer;     // 最大编辑长度
        IntLength : Integer;     // 整数部分最大长度
        DecLength : Integer;     // 小数部分最大长度

        LineWidth : Integer;     // 边框线宽
        PenStyle : TPenStyle;    // 线形(TPenStyle 为Delphi定义类型)

        // Number 用于存储额外的数据,甚至可以用 Pointer()
        // 强制成32位结构指针,使得网格理论上可以挂接任意类型的数据
        Number : Integer;        // 存储数值

        Color : TColor;          // 网格背景颜色

        FontSize: Integer;       // 字体大小
        FontColor: TColor;       // 字体颜色
        FontStyle: TFontStyles;  // 字体风格
        FontName : string;       // 字体名字
        ForeText : string;       // 前台 Text
        BackText : string;       // 后台 Text
      end;
      PCellInfo = ^TCellInfo;

  二、属性:(仅列出与DELPHI StringGrid 不同的部分)
     1、列在面板中的属性
        AlwaysDrawFocus   // 是否在失去焦点时仍然显示黑色的粗框
	AutoUpdate        // 该属性很重要,说明见上
	CellAlignMode     // 设置所有网格的默认属性(下同)
	CellAllowNegative
	CellAutoWordBreak
	CellColor
	CellDataStyle
	CellDecLength
	CellFontColor
	CellFontSize
	CellFontStyle
	CellIntLength
	CellLineWidth
	CellMaxLength
	CellPenStyle
	CellReadOnly
	CellShowForeText
	CellThousandSep
	CellTrailingZero
	CellZeroNull
	ClientLineColor   // 非固定区线条颜色
	FixedLineColor    // 固定区线条颜色
	ClientSizeable    // 非固定区是否允许用鼠标拖曳改变行高列宽
	ColCount          // 列数
        RowCount          // 行数
	Color             // 网格之外的背景颜色
	DefaultColWidth   // 缺省列宽
	DefaultRowHeight  // 缺省行高
	FixedCols         // 固定列数目(水平滚动时保持显示的列)
	FixedRows         // 固定行数目(垂直滚动时保持显示的行,一般用作表头)
  	GridCanCopyMove   // 是否允许交互式拖曳网格(点击黑色粗框)
	GridCanFill       // 是否允许交互式填充网格
	GridLineWidth     // 整个网格线条宽度
	HighLightColor    // 选中网格的背景颜色
	HighLightTextColor// 选中网格的文本颜色
	Option            // 其他属性(类似 StringGrid 的 Option)
	  goFixedVertLine // 是否显示固定区竖直线
	  goFixedHorzLine // 是否显示固定区水平线
	  goVertLine      // 是否显示非固定区竖直线
	  goHorzLine      // 是否显示非固定区水平线
	  goRangeSelect   // 是否允许用鼠标进行范围选择(选择多个单元格)
	  goDrawFocusSelected // 是否显示表示选中的单元格粗框
	  goRowSizing     // 是否允许用鼠标改变行高
	  goColSizing     // 是否允许用鼠标改变列宽
	  goEditing       // 网格是否可编辑
	  goTabs          // 是否允许用 TAB 键在列之间跳动
	  goRowSelect     // 是否一次选中一行(浏览模式)
 	  goAlwaysShowEditor // 是否总是显示编辑器
	  goThumbTracking // 滑动滚动条时是否同步滚动网格
        ScrollBars        // (ssBoth, ssHorz, ssVert)
        ShowColTitle      // 是否显示标题行(顶端标有A B C D的行)
        ShowRowTitle      // 是否显示标题列(左边标有1 2 3 4的列)
        TitleColor        // 标题区颜色
	FocusedTitleColor // 选中行列的 Title 区颜色
        ShowPopup         // 点击右键时是否显示属性设置菜单
     2、没有列在面板中的属性
        Canvas            // 画布属性
        Col               // 当前列
        Row;              // 当前行
        ColWidths         // 列宽数组(如:ColWidths[1] := 100)
        Aligns            // 对齐属性数组(如:Aligns[1,1] := taCenter)
        ForeTexts         // 前台文本数组(如:ForeTexts[1,1] := 'Hello')
        BackTexts         // 后台文本数组(如:BackTexts[1,1] := 'Hello')
        Colors            // 颜色属性数组(如:Colors[1,1] := clRed)
        Cells             // 说明见上
        Selection         // 当前选择区域 (TRect)
        RowHeights        // 类似 ColWidths
        ColCanSizes       // 列允许改变宽度数组(如:ColCanSizes[1] := False)
        RowCanSizes       // 行允许改变高度数组(如:RowCanSizes[1] := False)

  三、方法
        // 根据网格行列坐标计算网格的屏幕物理坐标(相对于 Grid 的左上角)
        function CellRect(ACol, ARow: Longint): TRect;

        // 计算物理坐标对应的网格的坐标
        procedure MouseToCell(X, Y: Integer; var ACol, ARow: Longint);

        // 强制更新 ARect 区域(Grid 坐标)
        procedure InvalidateRect(ARect: TGridRect);

        // 强制更新整个 Grid
        procedure InvalidateGrid;

        // 强制刷新一个 Cell ( Grid 坐标单位)
        procedure InvalidateCell(ACol, ARow: Longint);

        // 强制刷新一列 ( Grid 坐标单位)
        procedure InvalidateCol(ACol: Longint);

        // 强制刷新一行 ( Grid 坐标单位)
        procedure InvalidateRow(ARow: Longint);

⌨️ 快捷键说明

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