Delphi TStringGrid 类(1)

来源:互联网 发布:js清空select option 编辑:程序博客网 时间:2024/05/03 11:57

1。TStringGrid [1] - ColCount、RowCount、Cells

  cCount := StringGrid1.ColCount; {获取总列数} 

  rCount := StringGrid1.RowCount; {获取总行数}

{给每个单元赋值}

   for c :=0to StringGrid1.ColCount -1do   

      for r :=0to StringGrid1.RowCount -1do     

        StringGrid1.Cells[c,r] := Format('%d,%d', [c,r]);

 

2.DefaultColWidth、DefaultRowHeight、Col、Row

1、修改 StringGrid 单元的默认宽与高;
2、添加行和列;

{添加一行}
StringGrid1.RowCount := StringGrid1.RowCount + 1;

{添加一列}

 StringGrid1.ColCount := StringGrid1.ColCount +1;

c := StringGrid1.Col; {当前列}  r := StringGrid1.Row; {当前行} 

 StringGrid1.Cells[c,r] := Format('列:%d;行:%d', [c,r]);

 

3.FixedCols、FixedRows、Color、FixedColor

实体列,实体行,颜色,实体颜色

 

4.GridLineWidth : 方格线

StringGrid1.GridLineWidth:= StringGrid1.GridLineWidth + 1;
原创粉丝点击