How to programmatically scroll a DataGrid to a given row?

using System.Windows.Forms;
 
namespace Devintelligence
{
  /// <summary>
  /// ScrolledDataGrid.
  /// </summary>
  public class ScrolledDataGrid : DataGrid
  {
    public ScrolledDataGrid()
    {
    }
 
 
    /// <summary>
    /// scroll the grid to a particular row
    /// </summary>
    /// <param name="rowNumber"></param>
    public void ScrollTo(int rowNumber)
    {
      if (this.DataSource != null)
      {
        GridVScrolled(this, new ScrollEventArgs(ScrollEventType.LargeIncrement, rowNumber));
      }
    }
  }
}


 
 
 

Leave a Reply