//设置单元格是否可编辑 procedure TForm1.AdvStringGrid1CanEditCell(Sender: TObject; ARow, ACol: Integer; var CanEdit: Boolean); var i: Integer; begin for i := 0 to AdvStringGrid1.ColCount do begin CanEdit := False; end; if ACol = 1 then CanEdit := True; if ACol = 7 then CanEdit := True; end;
//设置单元格对齐方式 procedure TForm1.AdvStringGrid1GetAlignment(Sender: TObject; ARow, ACol: Integer; var HAlign: TAlignment; var VAlign: TVAlignment); begin if ACol = 1 then begin HAlign := taCenter; //TAlignment = (taLeftJustify, taRightJustify, taCenter); VAlign := vtaCenter; //TVAlignment = (vtaTop,vtaCenter,vtaBottom); end; end;
//添加CheckBox procedure TForm1.FormCreate(Sender: TObject); var i: Integer; flag: Boolean; begin //添加CheckBox for i := 1 to AdvStringGrid1.RowCount - 1 do begin AdvStringGrid1.AddCheckBox(1, i, False, false); end; //判断CheckBox是否选中 for i := 1 to AdvStringGrid1.RowCount - 1 do begin AdvStringGrid1.GetCheckBoxState(1, i, flag); if flag = true then begin //如果选中CheckBox进行操作 end; end; end;
时间: 2024-10-14 10:30:38