TDBGrid onSelect
I would like to customize TDBGrid:
1) add onSelect / onUnselect events - eg. useful for showing the number of selected items.
2) remove the selection with the left mouse button. I inherited TDBGrid and overwritten MouseDown, but then it is not possible to move or resize columns :(
So how do you do it?
D2009
+1
yippee
source
to share
4 answers
This does the job for me:
implementation
{$R *.dfm}
type
THackDBGrid = class(TDBGrid);
//for info on why we must do this, see:
//http://delphi.about.com/od/oopindelphi/l/aa082603a.htm
var
LastValidRow: integer;
procedure TForm1.DataSource1DataChange(Sender: TObject; Field: TField);
begin
//assign this to the TDBGrid.DataSource.DataSet.OnDataChange Event
if 0 <> HiWord(GetKeyState(VK_LBUTTON)) then begin
THackDBGrid(DBGrid1).Row := LastValidRow;
end
else begin
LastValidRow := THackDBGrid(DBGrid1).Row;
inherited;
end;
end;
+1
source to share
> I think you probably need to make sure that you allow the legacy Mousedown to work in such a way that the standard move and resize behavior follows.
But the inherited MouseDOwn makes a selection with the left mouse button and I only want to select / deselect with the right mouse button (like select / unselect in TotalComander)
0
yippee
source
to share