Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > Making the selected row of a Datagrid visible without having to scroll down manually.
 

Making the selected row of a Datagrid visible without having to scroll down manually.

I have a client app written in Visual Studio 2008 searching datagrid view by passing the customer number and the datagrid.
The Row is highlighted when the customer is found. Most of the time, the selected row is not on the first page of the Datagrid.

Is it possible to programtically to scroll down the data grid so the selected row is visble without having the user to manually to scroll down?

Thanks,


Private Sub getRowIndex(byval a_customer as string ByVal a_dgrd As DataGridView)
For Each lcRow As DataGridViewRow In a_dgrd.Rows
if lcRow.Cells("Customer").Value.ToString = a_customer Then
a_dgrd.Rows(lcRow.Index).Selected = True
End If
Next
End Sub

tlu  Saturday, July 18, 2009 6:09 PM
Hello ,
You can use Datagridview1.FirstDisplayedScrollingRowIndex . It is the index of the row that is the first row displayed on the datagridview.
  • Marked As Answer bytlu Saturday, July 18, 2009 11:26 PM
  •  
NareshG  Saturday, July 18, 2009 8:35 PM
Hello ,
You can use Datagridview1.FirstDisplayedScrollingRowIndex . It is the index of the row that is the first row displayed on the datagridview.
  • Marked As Answer bytlu Saturday, July 18, 2009 11:26 PM
  •  
NareshG  Saturday, July 18, 2009 8:35 PM

You can use google to search for other answers

Custom Search

More Threads

• Calling MDI Child Methods from MDI Parent Form Options
• a simple question about datagridview
• Can I tell if the header row in a bound grid is clicked
• where to open my connection object?
• How do to set the value of datagrid checkbox
• DataGridView parent/child relation
• How can I retrieve SELECT String from VB designer generated ADO objects
• images in combobox with binding source
• Xceed DataBound Master Detail Grid Control Problems
• Error when setting DataAdapter's .SelectCommand details