Solved

Want to scroll down TStringGrid: WM_MOUSEWHEEL message

Posted on 2003-12-02
2
799 Views
Last Modified: 2008-01-09
hi all,

I want to scroll automatically down in a TSTringGrid (borland cpp builder 6) when i add an item to the grid.  I haven't found yet how to do this.  I want that the latest added item is always visible and selected.
I tried to send a message to the stringgrid as if i would scoll on it with my mouse:

PostMessage((HWND)StringGrid1->Handle,WM_MOUSEWHEEL,1,1);

unfortunately this does not work.  Am i missing something?


Greetz
0
Comment
Question by:cleaverX
2 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 50 total points
ID: 9858445
PostMessage((HWND)StringGrid1->Handle, WM_VSCROLL ,SB_BOTTOM , 0);    // SB_BOTTOM, SB_LINEDOWN etc. - select what you need
0
 
LVL 15

Expert Comment

by:efn
ID: 9858675
Another way:

      StringGrid1->TopRow = StringGrid1->RowCount - StringGrid1->VisibleRowCount;

You can control the selection with the Selection property.  For example:

      TGridRect tgr;
      tgr.Left = tgr.Right = 0;
      tgr.Top = tgr.Bottom = StringGrid1->RowCount - 1;
      StringGrid1->Selection = tgr;

--efn
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

785 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