DataGridView SortOrder property not same type as parameter to DGV Sort method

The Sort method of the DataGridView has the following signature:



Dim dataGridViewColumnAs DataGridViewColumn
Dim directionAs System.ComponentModel.ListSortDirection
Dim dataGridView1As DataGridView
dataGridView1.Sort(dataGridViewColumn, direction)

The SortOrder property of the DataGridView is of type
System.Windows.Forms.SortOrder.

The question I have is why are they not the same? These
enumerations appear to have different underlying values. Thus,
you can't simply assign one to the other. If you want to track
the current sort order of a DGV you have to convert between
the two types. Is there some reason why they can't be the
same type?

[1078 byte] By [blkeller] at [2007-12-16]
# 1

They are different because you can set the SortOrder for a column to None, but you can't call the Sort() method with a None value.

We needed the Sort() method to be based upon ListSortDirection since that is what databinding uses, but we also needed a way for you to indicate that a column isn't sorted at all, thus the None value in the SortOrder enum.

Hope this helps,
-mark
DataGridView Program Manager
This post is provided "as-is"

MarkRideout at 2007-9-9 > top of Msdn Tech,Windows Forms,Windows Forms Data Controls and Databinding...