Board index » cppbuilder » TStringGrid

TStringGrid

To select a cell when the scroll bar is has been scrolled down.

void __fastcall TfrmMain::sgJobListMouseDown(TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y)
{
    Ccell Cell;
    CtraxJobList *JL;
    if( Shift.Contains( ssDouble ) == false )
        return;
    sgJob->MouseToCell(X,Y,Cell.C,Cell.R);
    if( Cell.C == -1 || Cell.R <= 0 )
        return;
    JL = (*vecJL)[ Cell.R - 1 ];
    PAD( JL->getDesc() ); // outputs this to a richedit

Quote
}

I have a vector of items, placed in the TStringGrid.  If I select one, it
gives me the absolute (mod) cell.  Not the cell selected.  Ie, if I select
row 1, then scroll to bottom of list and select visible row 1, it tells me
row 1.  I need the row selected, not the visible row.  How do I get this?

--
Charles Savage
Software Developer
HWI Manufacturing

 

Re:TStringGrid


Quote
Chuck Savage <csavage> wrote in message news:3b4e273f$1_2@dnews...
> To select a cell when the scroll bar is has been scrolled down.

> void __fastcall TfrmMain::sgJobListMouseDown(TObject *Sender,
>       TMouseButton Button, TShiftState Shift, int X, int Y)
snip
>     sgJob->MouseToCell(X,Y,Cell.C,Cell.R);
snip
> I have a vector of items, placed in the TStringGrid.  If I select
one, it
> gives me the absolute (mod) cell.  Not the cell selected.  Ie, if I
select
> row 1, then scroll to bottom of list and select visible row 1, it
tells me
> row 1.  I need the row selected, not the visible row.  How do I get

this?

Forgive me if I've misunderstood, but are you perhaps using the term
"selected" imprecisely?  If you select a cell and then scroll the
TStringGrid, the selected cell (which is usually blue) will still be
identified my myGrid->Row and myGrid->Col, regardless of whether you
can see it or not.

If you click the mouse on another cell (I think this is what you mean
the second time you write "selected", the Grid's selected cell will
change, and those properties will have new values.

--
Timothy H. Buchman
========================================
City Center Theater New York NY
tbuchmanPLEASE(at sign)REMOVEcitycenter.org
Please treat this signature information as confidential.
========================================
Search .borland newsgroup archives at:
http://www.mers.com/searchsite.html

Re:TStringGrid


The problem again, as the other example is being interpreted incorrectly.
Code put at end

Select a cell, it returns the visible cell selected.  I need the row within
the table.  Ie if I'm scrolled to the bottom, and row's from my table being
displayed are 110 through 119.  But when I select row 110 in my table on the
grid, which is the top visible movable row.  It gives me a value of 1.  Why
isn't it giving me the value of 110?  So how do I get it to give it to me?
The ScrollBar property of TStringGrid is only the vertical, horizontal,
none, or both value.  So I can't even determine how far down the thumb is on
the scroll bar.

The only solution I can think of is to have a hidden index displayed, or to
display one if I cannot and use that row selected String value as an index
back into my table.  Of course that is a cludge around a feature of
TStringGrid.

void __fastcall TfrmMain::sgJobListMouseDown(TObject *Sender,
      TMouseButton Button, TShiftState Shift, int X, int Y)
{
    Ccell Cell;
    CtraxJobList *JL;
    if( Shift.Contains( ssDouble ) == false )
        return;
    sgJob->MouseToCell(X,Y,Cell.C,Cell.R);
    if( Cell.C == -1 || Cell.R <= 0 )
        return;
    JL = (*vecJL)[ Cell.R - 1 ];
    PAD( JL->getDesc() );  // Display to Richedit

Quote
}

Re:TStringGrid


Bah, all my fault.  Works fine now.  Would help if I accessed the correct
TStringGrid with the MouseToCell() call.  Notice the method,
sgJobListMouseDown and I was using sgJob.  Bah!

And thanks for the suggestions.  SelectCell doesn't tell me if its a double
click.  Though I think you might be able to get that with a Mouse-> call of
some type.

Quote
> void __fastcall TfrmMain::sgJobListMouseDown(TObject *Sender,
>       TMouseButton Button, TShiftState Shift, int X, int Y)
> {
>     Ccell Cell;
>     CtraxJobList *JL;
>     if( Shift.Contains( ssDouble ) == false )
>         return;
>     sgJob->MouseToCell(X,Y,Cell.C,Cell.R);
>     if( Cell.C == -1 || Cell.R <= 0 )
>         return;
>     JL = (*vecJL)[ Cell.R - 1 ];
>     PAD( JL->getDesc() ); // outputs this to a richedit
> }

Re:TStringGrid


Might be an easier solution...why not use the SelectCell() function?  that
returns that returns the row and column of the selected cell

Weisen

Other Threads