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;
  • 相关阅读:
    CODE[VS] 3026 恶心的扑克
    CODE[VS] 2951 打字比赛
    CODE[VS] 2774 火烧赤壁
    CODE[VS] 1860 最大数 1998年NOIP全国联赛提高组
    matplotlib学习笔记(一)
    LUNA16数据集(二)肺结节可视化
    [转载]pytorch自定义数据集
    [转载]什么情况下应该设置 cudnn.benchmark = True?
    pytorch构建优化器
    pytorch批训练数据构造
  • 原文地址:https://www.cnblogs.com/CodeGear/p/4673792.html
Copyright © 2011-2022 走看看