Programmatically scroll the datagrid

K

Kev Westwood

How can you programmatically scroll the datagrid?

The standard framework datagrid has a protected member called GridVScrolled
which can be used to scroll the grid but it is not in the compact version.

Any ideas?

Thanks
Kevin
 
J

Jeje1307

How can you programmatically scroll thedatagrid?

The standard frameworkdatagridhas a protected member called GridVScrolled
which can be used to scroll the grid but it is not in the compact version.

Any ideas?

Thanks
Kevin

Did you find a solution for that problem ?
I'm currently facing the same issue, so your help will be
appreciated...
 
V

vijay

Did you find a solution for that problem ?
I'm currently facing the same issue, so your help will be
appreciated...

Set the Vertical scroll bar value to required row number.
here is the sample code. add validations as you required.

Class ScrollDataGrid
Inherits DataGrid
Dim fi As Reflection.FieldInfo

Public Function scrollto(ByVal ivalue As Integer) As Boolean
fi = Me.GetType().GetField("m_sbVert", BindingFlags.NonPublic
Or BindingFlags.GetField Or BindingFlags.Instance)
CType(fi.GetValue(Me), VScrollBar).Value = ivalue
Me.CurrentRowIndex = ivalue
End Function
End Class
 
J

Javier Ferri

hello, thanks for this code, but I have not been able to make it work in c#, could you translate this into this language, please?
Thanks
 
J

Javier Ferri

Ya lo encontr?:


using System.Reflection;

....

class BaseGrid : DataGrid {



/// <summary>

/// Scrolls datagrid to the row.

/// </summary>

/// <param name="rowNum">The row num.</param>

public void ScrollToRow(int rowNum)

{

FieldInfo fi = this.GetType().GetField("m_sbVert", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance);

((VScrollBar)fi.GetValue(this)).Value = rowNum;

}



}

Fuente:
http://dukelupus.wordpress.com/2009/03/13/how-to-scroll-datagrid-programmatically-in-net-ce/

Submitted via EggHeadCafe
Product Review: HP USB 2.0 Docking Station
http://www.eggheadcafe.com/tutorial...product-review-hp-usb-20-docking-station.aspx
 

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