• TStringGrid的Rows索引值 和 Cells的 索引值, Row的赋值


      Caption := sgShopList.Rows[sgShopList.RowCount +1000].CommaText;

    Caption := sgShopList.Rows[sgShopList.RowCount -1000].CommaText;

    Rows[]的索引值,可以超过 RowCount,但是不能 小于0

    Cells[]的索性值,读取时可以任意,包括-1 或者10000,不会报错。

      with TStringGrid.Create(Self )do
      try
        Parent := Self;
        ShowMessage( Cells[-1, 1000] );
      finally
        free
      end;
    function TStringGrid.GetCells(ACol, ARow: Integer): string;
    var
      ssl: TStringSparseList;
    begin
      ssl := TStringSparseList(TSparseList(FData)[ARow]);
      if ssl = nil then Result := '' else Result := ssl[ACol];
    end;

    写入时,不能是 -1,但可以是 100000等

      with TStringGrid.Create(Self )do
      try
        Parent := Self;
         Cells[100, 1000] := '123555';
         ShowMessage( Cells[100, 1000] );
      finally
        free
      end;
     
    
    function TSparseList.Get(Index: Integer): Pointer;
    begin
    if Index < 0 then TList.Error(SListIndexError, Index);
    Result := FList[Index]
    end;
        property Row: Longint read FCurrent.Y write SetRow;
    View Code
    procedure TCustomGrid.SetRow(Value: Longint);
    begin
      if Row <> Value then FocusCell(Col, Value, True);
    end;
    procedure TCustomGrid.FocusCell(ACol, ARow: Longint; MoveAnchor: Boolean);
    begin
    MoveCurrent(ACol, ARow, MoveAnchor, True);
    UpdateEdit;
    Click;
    end;
    procedure TCustomGrid.MoveCurrent(ACol, ARow: Longint; MoveAnchor,
      Show: Boolean);
    var
      OldSel: TGridRect;
      OldCurrent: TGridCoord;
    begin
      if (ACol < 0) or (ARow < 0) or (ACol >= ColCount) or (ARow >= RowCount) then
        InvalidOp(SIndexOutOfRange);
      if SelectCell(ACol, ARow) then
      begin
        OldSel := Selection;
        OldCurrent := FCurrent;
        FCurrent.X := ACol;
        FCurrent.Y := ARow;
        if not (goAlwaysShowEditor in Options) then HideEditor;
        if MoveAnchor or not (goRangeSelect in Options) then
        begin
          FAnchor := FCurrent;
          if goRowSelect in Options then FAnchor.X := ColCount - 1;
        end;
        if goRowSelect in Options then FCurrent.X := FixedCols;
        if Show then ClampInView(FCurrent);
        SelectionMoved(OldSel);
        with OldCurrent do InvalidateCell(X, Y);
        with FCurrent do InvalidateCell(ACol, ARow);
      end;
    end;
  • 相关阅读:
    Python常用第三方库总结
    Python爬虫技术--入门篇--爬虫介绍
    X sql解惑 25 里程碑问题 答案
    X sql解惑 34 咨询顾问收入问题
    从小变大的照片
    获取属性的顺序
    for...in
    判断元素是否存在
    自由的元素名称
    ES6语法糖-简洁属性表示
  • 原文地址:https://www.cnblogs.com/CodeGear/p/4673792.html
Copyright © 2020-2023  润新知