Wie zu verwenden SortMode in DataGridView

Ich versuche, das zu Sortieren, zu arbeiten für das DataGridView. Die Sortierung sollte automatisch sein, wenn ich Sie auf die Spaltenüberschriften, aber es funktioniert nicht. Was mache ich falsch?

private void LoadDummyData()
{
    List<AddressBookDummy> list = new List<AddressBookDummy>();
    list.Add(new AddressBookDummy { Name = "Newman, Alfred", Type = "CAR" });
    list.Add(new AddressBookDummy { Name = "Skywalker, Luke", Type = "SUP" });
    list.Add(new AddressBookDummy { Name = "Skywalker, Leia", Type = "BEN" });

    addressBookGrid.DataSource = list;
}

private void InitializeGrid()
{
    addressBookGrid.RowHeadersVisible = false;
    addressBookGrid.ScrollBars = ScrollBars.Vertical;
    addressBookGrid.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
    addressBookGrid.Columns[0].SortMode = DataGridViewColumnSortMode.Automatic;
    addressBookGrid.Columns[1].SortMode = DataGridViewColumnSortMode.Automatic;
}
InformationsquelleAutor Greg Finzer | 2011-11-04
Schreibe einen Kommentar