Hi Matt,
Thank you for posting.
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.
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.
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
You can refer to the below link for more information on the above three
options:
http://msdn2.microsoft.com/en-us/library/ms171608(d=ide).aspx
4. Using DataView and set the its Sort property
You can refer to he below link for more information on the option4:
http://msdn2.microsoft.com/en-us/library/system.data.dataview.sort(d=ide).as
px
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.
So in my opinion, it is impossible to sort a DataGridViewComboBoxColumn
based on the FormattedValue.
If you have other concerns, please don't hesitate to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
====================================================
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
====================================================