zoukankan      html  css  js  c++  java
  • 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;
  • 相关阅读:
    绝对路径相对路径
    LN项目重构之职责链模式
    年度回忆录(2011.072011.12)
    协议学习建议
    UBUNTU下制作软盘映
    从汇编看c语言函数调用
    计算机底层入门知识杂记(一)——计算机启动流程解析
    自己动手写操作体统 pmtest1.asm 详细解释
    汇编函数与C函数的相互调用
    嵌入式linux驱动开发班
  • 原文地址:https://www.cnblogs.com/CodeGear/p/4673792.html
Copyright © 2011-2022 走看看