• 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;
  • 相关阅读:
    MySql常用日期时间查询
    微信开发中网页授权access_token与基础支持的access_token异同
    Sqlserver复杂查询
    Array排序和List排序
    关于java按位操作运算
    验证redis的快照和AOF
    线程安全 加锁机制
    Redis 与 数据库处理数据的两种模式
    redis实现点击量/浏览量
    jsp网站访问次数统计的几种方法
  • 原文地址:https://www.cnblogs.com/CodeGear/p/4673792.html
Copyright © 2020-2023  润新知