I have a Winforms DataGridView with few columns which can be sorted and few which couldn't be. For columns which I don't want my gridview to be sorted I have set
dgvConnections.Columns[e.ColumnIndex].SortMode = DataGridViewColumnSortMode.NotSortable;
in
dgvConnections_ColumnHeaderMouseClick
event handler but I am unable to get rid of the the sort icon from the column header, as its presence could cause confusion to the user.
So kindly suggest me a way to get rid of the sorting icon from the column which cannot be sorted. Thanks in advance!
In C programming language, %d and %i are format specifiers as where %d specifies the type of variable as decimal and %i specifies the type as integer. In usage terms, there is no difference in printf() function output while printing a number using %d or %i but using scanf the difference occurs.
The letter c was applied by French orthographists in the 12th century to represent the sound ts in English, and this sound developed into the simpler sibilant s.
%d is used to print decimal(integer) number ,while %c is used to print character . If you try to print a character with %d format the computer will print the ASCII code of the character.
It looks like you are not maintaining the correct execution order. The code you wrote will do the work
dgvConnections.Columns[e.ColumnIndex].SortMode = DataGridViewColumnSortMode.NotSortable;
but make sure you are calling it after initializing the DataGridView.
If you want it for specific columns like you mentioned in your question, you need to find the index and set the sortmode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With