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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGrid CurrentRowIndex unwanted behavior

Status
Not open for further replies.

RexHeadlong

Programmer
Apr 10, 2002
35
US
I seem to be going crazy on this one.

I've got a derived DataGrid class, with standard row headers. When I set the CurrentRowIndex property, I get the little black chevron sitting on the desired row header, which is fine. But, at the same time, my grid is scrolled all the way to the left, which is not fine. Not to mention that this happens without the GridHScrolled method getting triggered.

Does anybody know if this is standard behavior for a DataGrid, or how to prevent this from occurring?

Thanks for any help.
 
You might need to set the current cell to preserve the current column. Additionally, you might need to use the rightmost column as the current column to preserve your horizontal scroll position.

When I tried to navigate for the user, I found that the current row was positioned at the bottom of the grid rather than the top. This was undesireable since the user was searching the contents of the grid. My workaround was to position the grid at the very last row, and then position to the row I wanted.

You will probably have to play a similar game to get the result you are looking for. Surprisingly, there was no significant screen flicker with my workaround.
 
Thanks for the post.
But what if my entire grid is read only and I don't want the current cell set at all?
Thanks.
 
That should not affect anything. The DataGrid will not enter edit mode even if you set the current cell. Its just an aid to navigation.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top