Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Apparently, this is not possible. I was looking for the same thing and I am not sure why no one would have thought this was an important feature. Here is the link to the original question and the answer from a Microsoft Rep.</p> <p><a href="http://www.webnewsgroups.net/vbnet/t25706-vb2005-sort-datagridview-text-formattedvalue-combobox-column-instead-underlying-value.aspx" rel="nofollow">http://www.webnewsgroups.net/vbnet/t25706-vb2005-sort-datagridview-text-formattedvalue-combobox-column-instead-underlying-value.aspx</a></p> <blockquote> <p>Hi Matt,</p> <p>Thank you for posting.</p> <p>If you have a DataGridViewComboBoxColumn in your DataGridView, you have to set the DataSource of the DataGridView to populate data in it. That's to say, you must bind the DataGridView to a datasource.</p> <p>If you set the SortMode of the DataGridViewComoboBoxColumn to Automatic, you can sort this column by clicking it. The sorting is based on the cells' value in the column, not the FormattedValue. If you want to sort this column based on the FormattedValue, it seems that you have to customize the sorting.</p> <p>There're several options for custom sort of DataGridView. These options are listed below. 1. Calling DataGridView.Sort(DataGridViewColumn,ListSortDirection) method 2. Handling with the DataGridView's SortCompare event 3. Calling DataGridView.Sort(IComparer) method</p> <p>You can refer to the below link for more information on the above three options: <a href="http://msdn2.microsoft.com/en-us/library/ms171608(d=ide).aspx" rel="nofollow">http://msdn2.microsoft.com/en-us/library/ms171608(d=ide).aspx</a></p> <ol> <li>Using DataView and set the its Sort property</li> </ol> <p>You can refer to he below link for more information on the option4: <a href="http://msdn2.microsoft.com/en-us/library/system.data.dataview.sort(d=ide).as" rel="nofollow">http://msdn2.microsoft.com/en-us/library/system.data.dataview.sort(d=ide).as</a> px</p> <p>It seems that only option2 and option3 could be applied to sort the DataGridViewComboBoxColumn based on the FormattedValue. However, these two options only apply under the condition that the DataGridView is NOT bounded to a DataSource.</p> <p>So in my opinion, it is impossible to sort a DataGridViewComboBoxColumn based on the FormattedValue.</p> <p>If you have other concerns, please don't hesitate to let me know.</p> <p>Sincerely, Linda Liu Microsoft Online Community Support</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload