Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

select & popup

Posted on 1997-04-17
2
Medium Priority
?
254 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

618 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