Abort sorting in DataGridView when row has been edited

mospsculumel

New Member
I have DataGridView with 2 columns. SortMode of first is set to Automatic.In this grid is a lot rows, and when I change value in the row, for example from xyz to abc I still in position where this row WAS. Edited row jumps to top.I want to abort this automatic sorting and I want call sorting by left click on column. BeI found some solution (code below + I set SortMode to Programmatically), but my row still jumping :/ Has anyone solution to tackle with this issue?\[code\]private void dataGridView1_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e){ if (e.Button == MouseButtons.Left) { DataGridViewColumn newColumn = dataGridView1.Columns[e.ColumnIndex]; SortOrder direction; if (dataGridView1.SortOrder == SortOrder.Ascending) { dataGridView1.Sort(newColumn, ListSortDirection.Ascending); direction = SortOrder.Ascending; } else { dataGridView1.Sort(newColumn, ListSortDirection.Descending); direction = SortOrder.Descending; } newColumn.HeaderCell.SortGlyphDirection = direction; }}\[/code\]
 
Back
Top