My DataGridView sorting method
does not work and would not be used wiht the compiler
.
public void LoadData(IList conTable)
{
var mtc = new Conversions();
dgvDetailedTable.DataSource = null;
dgvDetailedTable.DataSource = mtc.ToSortableBindingList(conTable);
dgvDetailedTable.RowTemplate.Height = UiConsts.RowHeight;
}
private void DgvDetailedTable_Sorted(object sender, EventArgs e)
{
var itemsToSelect = new MisTable[_selectedDetailedItems.Length];
_selectedDetailedItems.CopyTo(itemsToSelect, 0);
DgvOperations.MarkSelectedItems(dgvDetailedTable, itemsToSelect);
}
I hope this help, but I'm not sure you should use Sorted event for it. You can use this code below at the end of binding and when you add a new item it will sort properly again.
public void LoadData(IList conTable)
{
var mtc = new MisTableConversions();
dgvDetailedTable.DataSource = null;
dgvDetailedTable.DataSource = mtc.ToSortableBindingList(conTable);
dgvDetailedTable.RowTemplate.Height = UiConsts.RowHeight;
// Use sorting here
this.DgvDetailedTable.Sort(this.DgvDetailedTable.Columns["Name"], ListSortDirection.Ascending);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.