我正在使用 Lazarus 0.9.30.2。我有一个标准的 TForm,上面有一个标准的 TStringGrid。字符串网格在设计时没有列或行。在 Object Inspector 中设置了以下值。
ColCount = 0
Columns = 0
FixedCols = 0
FixedRows = 0
RowCount = 0
我想在运行时添加一些 TGridColumns,并且能够这样做,但总是得到一个固定的列,这是我不想要的。为此,我编写了与下面的示例非常相似的代码。当我编译并运行它时,我得到以下信息。
如何在运行时去除固定列并留下剩余的列?
unit test;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Grids;
type
TForm1 = class(TForm)
SgGrid: TStringGrid;
procedure FormCreate(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
procedure TForm1.FormCreate(Sender: TObject);
var
GridColumn : TGridColumn;
anIndex : integer;
begin
for anIndex := 0 to 5 do
begin
GridColumn := SgGrid.Columns.Add;
GridColumn.Width := 50;
GridColumn.Title.Caption := 'Col ' + inttostr(anIndex);
end; {for}
end;
end.