Datagridview sort by 2 Column??? [modified]
-
hi, i have a problem with datagridview sort methode. i doono whether i can sort datagridview by 2 Columns. there's example username--------actionType--------filename user1-----------download----------picture1.tiff ----------------upload------------picture2.jpg ----------------upload------------picture3.tiff user3-----------download----------file1.txt ----------------download----------file2.txt admin1----------upload -----------config.cfg ----------------download----------db1.mdb so there i wanna sort the table by 'filename' and 'username', i mean the order of username Column should not change but the order of 'filename' and the association of 'username' and 'filename' should not change neither. just like the effect in slq 'order by username, filename' has anyone a idea? regards faye -- modified at 4:54 Monday 15th January, 2007
-
hi, i have a problem with datagridview sort methode. i doono whether i can sort datagridview by 2 Columns. there's example username--------actionType--------filename user1-----------download----------picture1.tiff ----------------upload------------picture2.jpg ----------------upload------------picture3.tiff user3-----------download----------file1.txt ----------------download----------file2.txt admin1----------upload -----------config.cfg ----------------download----------db1.mdb so there i wanna sort the table by 'filename' and 'username', i mean the order of username Column should not change but the order of 'filename' and the association of 'username' and 'filename' should not change neither. just like the effect in slq 'order by username, filename' has anyone a idea? regards faye -- modified at 4:54 Monday 15th January, 2007
Use a BindingSource to bind your table to the DataGridView, then use the BindingSource's Sort property to specify the columns and directions to sort. E.g.:
bindingSource.Sort = "username, filename";
You can also specify the direction of the sort, e.g.:
bindingSource.Sort = "username ASC, filename DESC";