user3633580
user3633580

Reputation: 93

Delphi - dbGrid Select All

I put on a TwwdbGrid a checkbox field to select the record, I'd like to know if it's possible to put a checkbox on the label of the field on the grid and when the user click on it, it's select all the fields, anyone knows how to do that???

Example

Thanks in advance

Upvotes: 1

Views: 1656

Answers (1)

Rohit Gupta
Rohit Gupta

Reputation: 4191

The only way I can think of doing it is to use a TImageList and override DoCalcTitleImage. Heres a stripped down version where I have subclassed the grid and added support for various images on the columns.

procedure TRGDBGrid.DoCalcTitleImage(Sender: TObject; Field: TField;
  var TitleImageAttributes: TwwTitleImageAttributes);

begin
  inherited;
  { Get Image Number }
  lAttr := Attribute_Of_Field;
  TitleImageAttributes.ImageIndex := ord(lAttr);
end;

You can use two images - an unchecked and a check checkbox. And you need to use OnTitleClick event to handle it.

Upvotes: 1

Related Questions