Reputation: 179
I'm selecting a cell in my DataGridView programmatically:
myDataGridView.CurrentCell = myDataGridView.Rows[index].Cells[0];
/* The codes is here is not executed */
MessageBox.Show("Here");
my first column (column with 0 index) is hidden and when this line of code is executed, it shows undefined behavior(don't execute the continuous of method). Is this normal?
Edit: My Question changed to why this unhandled exception is not caught by Visual Studio?
Upvotes: 0
Views: 181
Reputation: 54457
Yes it is normal. The documentation for the CurrentCell
property specifically states that an InvalidOperationException
is thrown if:
The specified cell when setting this property is in a hidden row or column.
In future, if something doesn't work as you expect, make reading the relevant documentation the very first thing you do. It won't always give you the information you need but it often will. You should never be posting a question here or anywhere else without having read the relevant documentation first.
Upvotes: 1