冥界3大法王 发表于 2024-2-25 12:04

帮助中是这样写的:可是。。。

Vcl.Grids.TStringGridStrings.Clear
From RAD Studio API Documentation


[*]Up to Parent: TStringGridStrings


Delphi procedure Clear; override;
C++
virtual void __fastcall Clear();Properties
TypeVisibilitySourceUnitParent

procedure
functionpublic
Vcl.Grids.pas
Vcl.Grids.hppVcl.GridsTStringGridStrings
Description
Replaces all strings in the list with empty strings.
Call Clear to remove all strings from the list, including any references to associated objects. Clear replaces every string with an empty string and every object reference with nil (Delphi) or NULL (C++).
Note that Clear does not free the objects that are associated with strings in the list.



//StringGrid1.clear;       这种写法是错的!

方法1:
with StringGrid1 do
for i := 0 to ColCount - 1 do
    Cols.Clear;

方法2:
with StringGrid1 do
    for i := 0 to RowCount - 1 do
      Rows.Clear;

方法3:
    for i := 0 to StringGrid1.RowCount - 1 do
      for j := 0 to StringGrid1.ColCount - 1 do
      StringGrid1.cells := '';


那它具体 用在何处呢? 请举出一个实例!{:301_974:}
页: [1]
查看完整版本: 帮助中是这样写的:可是。。。