Quantcast
Viewing all articles
Browse latest Browse all 311

PowerShell GUIs • Datagridview and sorting

Hello everyone,

I have a datagridview that show result from a sql dataset. One of the column is a sequence of number. The user can change these number at will. What I'm trying to achieve right now is a way to trigger the datagrid sort on that column when I press the button. In fact, my whole idea is more than that, but I need to retrieve each row of the datagrid ordered on that specific column.

Let's say I have this. Column 1: Sequence, Column 2: App
1 | 7-zip
3 | Firefox
8 | Greenshot
4 | Onedrive
18 | Google drive

When the user press on the button, I want the list to be ordered by the sequence number but I also want to order them back in a 1-2-3-4 list. I already have the code that does that, but it require to have the list ordered first. So the button would first trigger the column sorting on the datagrid, making the datagrid show
1 | 7-zip
3 | Firefox
4 | Onedrive
8 | Greenshot
18 | Google drive

But then after, it would update the list to be
1 | 7-zip
2 | Firefox
3 | Onedrive
4 | Greenshot
5 | Google drive

Maybe I'm doing it wrong by trying to order the datagrid first, maybe there's a way to get the rows from the datagrid ordered directly in the code and just update the datagrid once all processing is done?

Thank you

Statistics: Posted by jsfrenette — Mon Dec 09, 2024 8:35 am — Replies 0 — Views 129



Viewing all articles
Browse latest Browse all 311

Trending Articles