如何在TStringGrid中添加或删除一行?

bobzh 2000-05-18 10:51:00
...全文
334 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
madfish 2000-05-21
  • 打赏
  • 举报
回复
对的, MoveRow 和 MoveColumn 是 TCustomGrid 的 protected 方法.
你需要创建自己的控件,
TExCell = class(TStringGrid)
public
procedure DeleteRow(ARow: Longint);
procedure DeleteColumn(ACol: Longint);
procedure InsertRow(ARow: LongInt);
procedure InsertColumn(ACol: LongInt);
end;
halfdream 2000-05-20
  • 打赏
  • 举报
回复
有这两个方法,不过不能在外部访问。
就象madfish 那样说的,你自己建一个组件继承自TStringGrid ,
就这么改两下就行了。
madfish 2000-05-19
  • 打赏
  • 举报
回复
删除某行/列,在某行/列插入新的一行/列,方法如下:

procedure TExCell.InsertColumn(ACol: Integer);
begin
ColCount :=ColCount +1;
MoveColumn(ColCount-1, ACol);
end;

procedure TExCell.InsertRow(ARow: Integer);
begin
RowCount :=RowCount +1;
MoveRow(RowCount-1, ARow);
end;

procedure TExCell.DeleteColumn(ACol: Longint);
begin
MoveColumn(ACol, ColCount -1);
ColCount := ColCount - 1;
end;

procedure TExCell.DeleteRow(ARow: Longint);
begin
MoveRow(ARow, RowCount - 1);
RowCount := RowCount - 1;
end;

bobzh 2000-05-19
  • 打赏
  • 举报
回复
没有MoveRow和MoveColumn方法呀。
supershan 2000-05-18
  • 打赏
  • 举报
回复
直接改给ROWCOUNT赋值,就可更改行数

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧