Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Right Click sense dbGrid Title

Status
Not open for further replies.

Pontelo

Programmer
Dec 18, 2001
80
BR
Hi people. A Lithe question.
We activate a PopUp on a dbGrid event "onTitleClick"
that will save, restore or exclude columns for users customize the grid layout. We would like to activate the PopUp on mouse right click. But how do we sense when user right clicked ?
I examined Mouse variable but found nothing about.
Thanks in advance !
 
One possible way to achieve what you want is to show the pop-up OnMouseDown rather than OnTitleClick. OnMouseDown event gives you more information about the mouse click. The example below may clarify a little more.

Code:
procedure TForm11.DBGrid1MouseDown(Sender: TObject; 
                                   Button: TMouseButton;
                                   Shift: TShiftState; 
                                   X, Y: Integer);
begin

  //Make sure right button is clicked over the grid title
  if (button= mbRight) and (DBGrid1.MouseCoord(X,Y).Y=0)then
    ShowMessage('Your code here');
  
end;

I hope this helps.


"It is in our collective behaviour that we are most mysterious" Lewis Thomas
 
I noticed that onTitleClick is activated only by left button. Your code worked well.
Thank you Bledazemi !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top