How to do something when you click on a specific column in a DBGrid ?

  • What language? - sharok

1 answer 1

If you mean the column header (title) in Delphi, then you can implement sorting:

 procedure TForm1.dbgItemsTitleClick(Column: TColumn); begin case Column.Index of 1: begin /*второй столбец, поле дата*/ DataModule1.ADOQuery1.Sort := 'date_s ASC'; /*сортировка по возростанию*/ 2: begin /*третий столбец, поле имя клиента*/ DataModule1.ADOQuery1.Sort := 'name_client DESC'; /*сортировка по убыванию*/ end; end; 

In general, invent yourself, the main thing is that you can match the index of the column and the corresponding field in the table (query).