Solved

select & popup

Posted on 1997-04-17
2
238 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 50 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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 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