How to disable row shifting when column is sorting in datatable
See original GitHub issueWhen it is sorted, when I give a value to the cell, the row moves. I don’t want this to happen. I work with DataGridView and DataTable . (vb.net-vs2019)
This is a weakness in ‘DataTable’ or ‘DataGridView’?
the biggest problem. Will this problem be solved in the future? In other versions of DataTable or DataGridView.
It would be great if it had an option named (orderFix).
How can this feedback be reported?
Dim MyDataTable As New DataTable
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
MyDataTable.Columns.Add("id")
MyDataTable.Columns.Add("f1")
MyDataTable.Columns.Add("f2")
MyDataTable.Columns.Add("f3")
MyDataTable.Rows.Add({"1", "a1", "b1", "c1"})
MyDataTable.Rows.Add({"2", "a2", "b2", "c2"})
MyDataTable.Rows.Add({"3", "a3", "b3", "c3"})
dgv.DataSource = MyDataTable
'There is no difference between the two (Programmatic /NotSortable)
dgv.Columns(0).SortMode = DataGridViewColumnSortMode.Programmatic' /NotSortable
dgv.Columns(1).SortMode = DataGridViewColumnSortMode.Programmatic '/NotSortable
dgv.Columns(2).SortMode = DataGridViewColumnSortMode.Programmatic' /NotSortable
dgv.Columns(3).SortMode = DataGridViewColumnSortMode.Programmatic' /NotSortable
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
MyDataTable.DefaultView.Sort = "[f2] asc"
End Sub
Issue Analytics
- State:
- Created 3 months ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
How to disable row shifting when column is sorting in ...
When it is sorted, when I give a value to the cell, the row moves. I don't want this to happen. I work...
Read more >How to disable row shifting when column is sorting in ...
When it is sorted, when I give a value to the cell, the row moves. I don't want this to happen. I work...
Read more >disable sorting on specific row using css class
i have only one problem in my implementation: i have a grid with column that i don't want to be sortable (there are...
Read more >How to disable sorting in Table visual
1. Create a blank button or blank rectangle · 2. Place it over the Table columns (Make sure you place the blank button/rectangle...
Read more >Data Grid - Sorting
Easily sort your rows based on one or several criteria. ... Hold down the Ctrl or Shift (use ⌘ Command on macOS) key...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@idmansourid I didn’t find a default property or method to achieve that in DGV control, but maybe you can try below workaround to sort only column f2 in an array and re-assign values to column f2.
I posted this question in (StackOverflow) but unfortunately it was closed due to lack of attention and (downvoting). And now I am blocked from posting questions in (StackOverflow).I couldn’t find a way to get out of being blocked (StackOverflow). I’m still blocked.