• advstringgrid笔记


    一下操作是在advstringgrid7.4.6.3版本下有效,advstringgrid控件名设置为 zy

    一、属性设置

    1.修改单元格内的值:zy.cells[col,row]='value';

    2.设置字体:属性找到Font设置普通单元格内字体,Fixfont设置列行标题字体;

    3.设置某单元格背景颜色,zy.Colors[acol,arow] := RGB(255,116,56);

    4.设置某行字体zy.RowFontColor[i] := clred;

    5.多行设置,属性Options内,gorowsizing=true,属性WordWarp=true,初始化zy后添加

      zy.DefaultColWidth := 200;//某人列宽
      zy.AutoSizeColumns(false,5);
      zy.AutoSizeRows(false,5);

    6.点击单元格后直接变成编辑状态:属性MouseActions内DirectEdit=true、CaretPositioning=True;

    7.修改行高列高:Options-> goRowsizing=true、goColsizing=true;

    8.设置成可编辑状态:Options->goEditing=true;

    9.设置回车后向后、下移动单元格:属性Navigation下,AdvanceOnEnter:=true;

    10.滚动条滚动到某格:ZY.ScrollInView(col,row,spMiddle);//(spMiddle 剧中, spTrailing 尾随不知道啥意思, spLeading 居首);

    11.修改Options属性:zy.Options :=  zy.Options+ [goEditing];

    12.CheckBox:ZY.AddCheckBoxColumn(3,false,false);//添加列   Zy.SetCheckBoxState(3,i,true);//设置为选中

        c.GetCheckBoxState(3,i,cs);//获取选中状态 先定义:cs : TCheckBoxState;
            if cs = cbChecked  then

    13.排序:很简单,属性 SortSetting->show=true;在cansort事件内设置列是否可以排序

    二、事件说明

    1、Onselectcell:选择单元格,可以设置某行、某列、某格是否可选

    if acol in[0,1] then
        canselect := false;

    2.OnEditCellDone:单元格编辑结束后触发。

    3.OnEndColumnSizeOnEndRowSize:改变列行宽度高度后触发,对应要进行zy.AutoSizeRows(false,5);zy.AutoSizeCols(false,5);

    4.OnGetColumnFilter:过滤设置,首先将属性FilterDropDownAuto设置为True;

      窗体初始化里面加入 zy.AutoFilterUpdate := true;

      然后在给zy填充数据的地方设置zy.filter.clear;

      然后在此事件内如下代码

      if not (Column in[pcdmi,kldmi]) then
          Filter.Clear;//设置哪下列有过滤

    也可以添加新过滤

      Filter.add('');

    4.OnMouseMove:鼠标移动,配合zy.MouseToCell(x,y,cc,cr);注意cc,和cr是可写变量,cc,cr为x,y坐标得到的单元格行列。

    5.OnGetEditType

      procedure TFModify.xyspcjGetEditorType(Sender: TObject; ACol, ARow: Integer;

      var AEditor: TEditorType);
      begin
        if (ARow = 2) and (ACol in [7,8,9,10,11,12,13,14,15,16,17]) then
       begin
          AEditor := edComboList;
          xyspcj.ClearComboString;
          xyspcj.AddComboString('A');
          xyspcj.AddComboString('B');
          xyspcj.AddComboString('C');
          xyspcj.AddComboString('D');
          xyspcj.AddComboString('E');
          xyspcj.AddComboString('');
        end;
      end;

  • 相关阅读:
    mysql用户
    mysql字符集
    tidb之一致性算法raft学习
    更新港资股票数据
    php中的时区设置
    PHP 中的注释
    python下如何处理windows的路径名
    安装第三方模块
    偏函数
    装饰器没学明白,记录一下,以后再学
  • 原文地址:https://www.cnblogs.com/theonewu/p/5053056.html
Copyright © 2020-2023  润新知