NextGrid 控件使用随手笔计(1)

1. 删除选中行内容
var
  str:string;
  i,j: integer;
begin
  i:=0;
  While (i<NextGrid1.RowCount)  do
  begin
     if NextGrid.Selected[i] then
     begin
        NextGrid1.DeleteRow(i);
        i:=0  //删掉一行后,总行数减少,要重新开始计数
     end else
        i:=i+1;
  end;
end;

2. 从指定的列/行  获值或赋值: 

获值:  Str:=NextGrid1.Cell[Col,Row].AsString;  // Col: 列号   Row: 行号 ;  均从0开始计数

赋值: NextGrid1.Cell[Col,Row].AsString:='Hello!';

3. 单元格为CheckBox控件使用方法:

NextGrid 控件使用随手笔计(1)

1. 先将该列Type设置成TNxCheckBoxColumn,

2. 在NextGrid1控件OnFooterClick事件内写代码:

procedure TfrmMain.NextGrid1FooterClick(Sender: TObject; ACol: Integer);

begin

 if (ACol = 1) and (NextGrid1.RowCount>0) then  // ACol=1代表第1列  NextGrid1.RowCount 存在的行号

   begin    

        for I := 0 to NextGrid1.RowCount -1 do    

         begin      

                             begin           

                                     if NextGrid1.Cell[1,i].AsString='False' then              

                                        NextGrid1.Cell [1,i].AsString :='True'     //反选           

                              else              

                                      NextGrid1.Cell[1,i].AsString:='False';      //取消    

          end; 

   end;

end;

 

你可能感兴趣的:(grid)