How do I set the of the datagrid horizontal scroolbar position?

G

Guest

I want the horizontal scrollbar location to be altered during runtime.

I have read msdn, and the scroolbar property of the datagrid is readonly, so
there seems to be no apparent way to simply set it.

My next guess was to override the HorizScrollbar property and play wiht the
datagrid controls collection... but I was unsuccessful

How should I do it?? Wha I really need is a public property of the datagrid
that allow me to set and get the horizontal scrollbar location at runtime.

kind regards
Henrik
 
K

Ken Tucker [MVP]

Hi,

For Each ctrl As Control In DataGrid1.Controls

If TypeOf ctrl Is HScrollBar Then

With DirectCast(ctrl, HScrollBar)

Trace.WriteLine(String.Format("Max {0} Min {1} Value {2}", .Maximum,
..Minimum, .Value))

End With

End If

Next



Ken

--------------------------------------

message I want the horizontal scrollbar location to be altered during runtime.

I have read msdn, and the scroolbar property of the datagrid is readonly, so
there seems to be no apparent way to simply set it.

My next guess was to override the HorizScrollbar property and play wiht the
datagrid controls collection... but I was unsuccessful

How should I do it?? Wha I really need is a public property of the datagrid
that allow me to set and get the horizontal scrollbar location at runtime.

kind regards
Henrik
 
G

Guest

Hi!

Yes that I already know (how t get the Hscrollbar object). The problem I
have is how to programatically make it slide to a certain position (value
property).
For example when I do this:

DirectCast(ctrl, HScrollBar).Value = DirectCast(ctrl, HScrollBar).Value + 10

the slider is indeed moving, but not the datagrid content... Do I miss to
make some kind of refresh, to bind the position of the content of the grid to
the hscrollbar position?

kind regards
Henrik
 

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