Reputation:
I would like to customize TDBGrid:
1) add onSelect/onUnselect events - e.g. good for show count of selected items.
2) remove select item on left mouse click. I have inherited TDBGrid and rewritten MouseDown, but then it is not possible to move or resize columns :(
So, how to do it?
D2009
Upvotes: 1
Views: 1426
Reputation: 58795
This gets the job done 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;
Upvotes: 1
Reputation: 5695
You would need to check changes in the Selected property.
Upvotes: 1
Reputation:
> I think you probably need to make sure you allow the inherited Mousedown to run so that the standard move and resize behaviour will execute.
But inherited MouseDOwn make select on left mouse button and I want only select/unselect on right mouse button (such as select/unselect in TotalComander)
Upvotes: 0
Reputation: 11221
I think you probably need to make sure you allow the inherited Mousedown to run so that the standard move and resize behaviour will execute.
Upvotes: 0