I have problem with datagridview
.
At start I disabling sorting in column(dictionaryDataGridView_ColumnAdded
and in designer)
When I doubleclick at columnheader sorting enables.
And it works.
When I doubleclick again at columnheader disabling.
And when I check SortMode of this column is NotSortable.
That is great.
But, when now I change value in row, it sorting my column.
It's very stressful for user, which lost from sight his row, and for me because I can't abort this sorting.
In dictionaryDataGridView_CellEndEdit
I see that's SortGlyphDirection
is set to None
, and SortMode
is set to NotSortable
, so It'couldn't sort, but sorts.
Does anyone know why is that? Is it bug in datagridview, or I miss something?
private void dictionaryDataGridView_ColumnHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.ColumnIndex == 0)
{
var column = dictionaryDataGridView.Columns[e.ColumnIndex];
if (column.SortMode != DataGridViewColumnSortMode.Programmatic)
{
column.SortMode = DataGridViewColumnSortMode.Programmatic;
dictionaryDataGridView.Sort(this.dictionaryDataGridView.Columns[0], ListSortDirection.Ascending);
this.dictionaryDataGridView.Columns[0].SortMode = DataGridViewColumnSortMode.Programmatic;
this.dictionaryDataGridView.Columns[0].HeaderCell.SortGlyphDirection = SortOrder.Ascending;
}
else
{
column.SortMode = DataGridViewColumnSortMode.NotSortable;
}
}
}
private void dictionaryDataGridView_ColumnAdded(object sender, DataGridViewColumnEventArgs e)
{
e.Column.SortMode = DataGridViewColumnSortMode.NotSortable;
}
private void dictionaryDataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
var aaa = this.dictionaryDataGridView.Columns[0].HeaderCell.SortGlyphDirection;
}