Question DataGridview preventing top row being selected.

Joined
Mar 18, 2014
Messages
18
Location
Devon, UK
Programming Experience
3-5
Hi.
Just started toying with the DataGridview, and realising what a complex control it can be.

I've got a DGV that has a total row at the very top that totals up figures beneath it. All that works fine. This row is shaded a different colour and is read only.
What I want to do is prevent that row from being selected, as when the control loads the row pointer is against the top row..... so if row 1 (index(0)) is selected when the form is loaded then the 2nd row should be selected instead (index(1)).
What we also need to put in place is that if the user clicks in the top row, then the request gets cancelled and the row pointer stays on the current row instead.

What's the easiest way for this to be done? I've tried doing this looking at various properties, but it always seems like I'm trying to modify a property that is read-only so want to know what properties I have to use to get this to work.

Should be simple enough.

Thanks for your help in advance.
 
Last edited:

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,553
Location
Sydney, Australia
Programming Experience
10+
Yeah, but whats the syntax to select a specified row?
In actual fact, it's not selection that you are really interested in. Selection just means being highlighted, which can be done for multiple rows at the same time. Only one row can be the current row and that's what you need to worry about. In order to make a row the current row, you need to make a cell in that row the current cell, so that's what you need to look at, i.e. the CurrentCell property.
 
Top Bottom