Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select a row in datagrid 1

Status
Not open for further replies.

swetham

Programmer
May 5, 2010
257
DE
I have placed a month calendar & data grid in windows form. Datagrid is filled up with holiday dates. When a user selects a date, particular holiday date in the grid should be highlighted & seen to the user.Code is,

in month_calendar_datechanged event

For _i = 0 To DGV_Holidays.Rows.Count - 1

If e.Start.ToString("dd-MMM-yyyy") = Mid(DGV_Holidays.Item(0, _i).Value, 1, 11) Then
DGV_Holidays.Rows(_i).Selected = True

End If
Next

The datagrid contains 100 dates. when i select the holiday date in calendar, equivalent date is getting highlighted but the row is not seen (ie, Selected date position is 79th. the datgrid vertical scroll should move to 79th position)

Can anyone please help me out from this issue?

Thank you
 

Use the DataGridView.FirstDisplayedScrollingRowIndex property to do this.


For _i = 0 To DGV_Holidays.Rows.Count - 1

If e.Start.ToString("dd-MMM-yyyy") = Mid(DGV_Holidays.Item(0, _i).Value, 1, 11) Then
DGV_Holidays.Rows(_i).Selected = True
[red]DGV_Holidays.FirstDisplayedScrollingRowIndex = _i[/red]
End If
Next

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top