Scrolling the datagrid

G

Guest

I have a datagrid derived class where i want to scroll the horizontal scroll
bar to the right. i tried the following code:

HScrollBar sb = (HScrollBar)base.GetType().GetField("m_sbHorz",
BindingFlags.NonPublic|BindingFlags.GetField|BindingFlags.Instance).GetValue(this);
sb.Value=5;

but i received a NullReferenceException in System.Windows.Forms.DataGrid.Dll,
I tried the following code and the same exception happened


HScrollBar sb = (HScrollBar)base.GetType().GetField("m_sbHorz",
BindingFlags.NonPublic|BindingFlags.GetField|BindingFlags.Instance).GetValue(this);

System.Reflection.PropertyInfo pi=sb.GetType().GetProperty
("Value",BindingFlags.Public | BindingFlags.Instance );

pi.SetValue (sb,90,null);


any suggestions??
 
G

Guest

i found the bug it was initialization problem, thanks for the reply
Does anyone know how to do this in a listview??
 
G

Guest

this method will scroll the listview top or down (vertical),
what about scrolling to the right or the left (horizonal)??
 

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