0

Okay so I know this is probably an easy question but I am tired and I want to find a good way to do this. The code below will show what I am getting into (I'll explain more after it)

string loc = dataGridView1.SelectedRows.ToString();
int loc2 = Convert.ToInt32(loc);

Anyway this little code goes into a if loop and has to deal with removing data off a datagridview without the risk of the user not clikcing anything and having it go into, a null pointer issue. I but the the think it when the I do that second line of code it has thrown this error "Input string was not in a correct format". I know I have run into this error and just went around it but now I want to find a proper way to do this

Edited by JOSheaIV: n/a

2
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by JOSheaIV
1

SelectedRows is a collection.
If you debug you will find that loc == "System.Windows.Forms.DataGridViewSelectedRowCollection"

0

Thanks for pointing that out yeah I fixed it with this line

int loc = dataGridView1.CurrentCellAddress.Y;
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.