?
Solved

select & popup

Posted on 1997-04-17
2
Medium Priority
?
248 Views
Last Modified: 2010-04-04
How can I make right-clicking a TStringGrid select the cell the mouse is over and just then pop up the popupmenu?
0
Comment
Question by:alona041797
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
CFantin earned 100 total points
ID: 1335445
Try this bit of code.

You need to place a popup menu on your form and assign it to your
StringGrids popup menu.

procedure TForm1.StringGrid1MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var ACol, ARow: LongInt;
begin
  {Check if the mouse button pressed was the right button}
  if Button = mbRight then
  begin
    {Get the Row and Col click on}
    StringGrid1.MouseToCell(X, Y, ACol, ARow);
    {Check that the user clicked on a valid Row and Col}
    if (ACol <> - 1) and (ARow <> - 1) then
    begin
      {Check if the user has not clicked on a fixed col or row
      as you cannot select a fixed col or row}
      if (StringGrid1.FixedCols <= ACol) and (StringGrid1.FixedRows <= ARow) then
      begin
        {Make the current selection equal to the Row and Col clicked on}
        StringGrid1.Col := ACol;
        StringGrid1.Row := ARow;
      end;
    end
  end;
end;

0
 
LVL 2

Author Comment

by:alona041797
ID: 1335446
Thanks a lot.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month11 days, 20 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question