(转)stringgrid删除选中行

定义一个从TStringGrid类继承的新类如下: 
type
TMyGrid = class(TStringgrid);

之后,删除时:你可以这样写:
TMyGrid(Grid).DeleteRow(Grid.Row); //Grid为你的StringGrid控件

说明:DeleteRow方法是TCustomGrid类申明的protected方法,可以删除表格中的一行;而TStringGrid没有将这一方法公开出来(意味着其他类将无法访问),所以你只需要定义一个从TStringGrid类继承的新类就可以了。

这个好像有点问题,下面的这个是可以:

procedure TForm1.deleteClick(Sender: TObject);
var
i_row,j_col:integer;
begin
stringgrid1.Rows[stringgrid1.row].Clear;
for j_col:=0 to stringgrid1.colcount do
for i_row:=stringgrid1.Row to stringgrid1.rowcount-1 do
stringgrid1.cells[j_col,i_row]:=stringgrid1.cells[j_col,i_row+1];
stringgrid1.RowCount:=stringgrid1.RowCount-1;
  stringgrid1.Refresh; 
end;



控制edit中只能输入数字??

procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
  if not (Key in ['0'..'9', #8,‘.’, #13]) then
begin
Key := #0;
ShowMessage('只能输入数字');
end;
end;


stringgrid的列隐藏通过 grdView.ColWidths[col]:=0; //列隐藏  col指所在的列


StringGrid .ColCount :=10;
StringGrid .Cells[0,0]:='材料编号';
StringGrid .Cells[1,0]:='供应商';

StringGrid .ColWidths[0]:=0; //列隐藏

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值