Argument exception thrown in form.ShowDialog () when I change the sort order of the form data grid

Well, I'm completely confused by this situation, so bear with me.

In my application, if you click on the button, my editor form will open

dgEditor = new fmDataGridFieldEditor();
dgEditor.ShowDialog();

This works great and my form appears and works correctly. The form contains a data grid with certain fields. Now, if I then change the data in one of the datagrid columns (a column that is only for numbers), and then change the sort order by clicking on the column heading, my form will work. with an error ArgumentExceptionthat says: "The object must be of type Int32" on the line dgEditor.ShowDialog();.

I do not understand what is happening or even how to start debugging this. This does not happen when I modify existing lines or if the lines that I enter are already sorted (for example, 0,1,2 is fine, and 0,1, 0 causes a crash).

In addition, I have a visual studio 2010 installation that breaks all exceptions, not just the unhandled ones, but I get the exception in the same place.

Finally, I connected the data grid event ColumnSortModeChangedto display the message box, but even if the sortings do not break the form, the message box does not appear.

I don’t understand how to do this.

+3
source share
3 answers

, . ShowDialog(). Debug + Windows + Call, .NET, . , , . DataGridView , , Reference Source. , , , , .

, . , , . CellValidating, .

+2

VB. , , , int. VB, , , - , , , . , . , - .

+1

ShowDialog , PictureBox TableLayoutPanel. PictureBox , , MemorySTream .

0

Source: https://habr.com/ru/post/1794525/


All Articles