How to auto scroll a datagrid?

S

Soulless

Hi,

I have a datagrid (rather a dataset I guess) that I update with
addStatusRow ( ... ). It basically is a Status that adds lines as
something occurs in my thread. As lines are entered, when it gets to
the bottom of the grid, I would like it to automatically scroll, so
the user does not need to use the scroll bar.

Is this easily done?

I have the code:

dsStatus1.Status.AddStatusRow(ibrFixSession.Status,
System.DateTime.Now.ToLongDateString() + " " +
System.DateTime.Now.ToLongTimeString());

AddToLog(ibrFixSession.Status);

dataGridSessionFix.CurrentRowIndex =
dsStatus1.Status.Rows.Count;

I was hoping that the last line will scroll my datagrid to the last
record, but does not work. The dsStatus1 is bound to the grid. It
is the dsStatus1 that has the rows added. Any ideas if or how I
could get this to work?

Thanks!
 
K

Kerem Gümrükcü

Hi Soulless (is this your real name?),

if something has a scrollbar, then you can send a
Message to it to make it scroll. See here Messages
and Notifications section for more information. Once
again: If someting has a scrollbar, it can be scrolled
with the windows api and in our case with pinvoking
of the native windows functions like SendMessage
and the Scrollbar Functions:

[Scroll Bar]
http://msdn2.microsoft.com/en-us/library/bb787529.aspx

Hope this helps,...

Regards

Kerem

--
 
S

Soulless

Hi Soulless (is this your real name?),

if something has a scrollbar, then you can send a
Message to it to make it scroll. See here Messages
and Notifications section for more information. Once
again: If someting has a scrollbar, it can be scrolled
with the windows api and in our case with pinvoking
of the native windows functions like SendMessage
and the Scrollbar Functions:

[Scroll Bar]http://msdn2.microsoft.com/en-us/library/bb787529.aspx

Hope this helps,...

Regards

Kerem

--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Microsoft Live Space:http://kerem-g.spaces.live.com/
Latest Open-Source Projects:http://entwicklung.junetz.de

Hey, Thanks!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top