Programmatically scroll the datagrid

  • Thread starter Thread starter Kev Westwood
  • Start date Start date
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
 
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...
 
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
 
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
 
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
 
Back
Top