Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

how to sort a gdatagridview by 2 columns

$
0
0

hi ,my code is like that                                                                

                dataGridView1.Sort(nameDataGridViewTextBoxColumn, ListSortDirection.Ascending);
                dataGridView1.Sort(levelDataGridViewTextBoxColumn, ListSortDirection.Ascending);
                for (int i = 0; i < dgvMainGrid.ColumnCount; i++)
                {
                     dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
                }

i hope that it can sort first by level,if the level is the same,then by name

like

name level

bbb    1

zzz    1

aaa    2

fff     2

     but i found it is only sorted by level

     could anyone can do me a favor to help me?

  btw,i use ( dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;) for forbidden the user in runtime to sort

   thank u very much in advance

best regards

martin



Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>