Solved

select & popup

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

708 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now