Hi!
I have a game i'm making and i would realy love to have a top 10 high score list at the end.
But here's where I'm stuck - I tried writing the whole thing into a .txt file (check), then i put all the scores from the .txt file into a datagrid (check
), and finaly i tried to sort them acording to the score (collumn "Score") (FAILURE!
). Because when I use the sort command it sorts everything by the first digit.
Example:
I have scores: 80, 10, 110 and 50.
And what it does is sort them like this: 80, 50, 110, 10 insted of 110, 80, 50, 10.
I changed the value type to int but that didn't work.
Then I got a little upset and made a whole SQL database just for this but when i make a connection with it and then try to open it in visual studio, it makes an instance failure (i googled for this problem, try the solutions, like making the SQL server type "Local system", but none of them worked for me).
I'm trying to make this work for some time now but just have no luck with it.
I would be more than happy if somebody helped me out (with a solution or another way to do the whole scoring thing).![]()
The DataGridView.Sort() method has 2 overloads. You can just insert the data you want to OR you can use the 2nd overloaded method and specify a ListSortDirection. Basically where you haveadd , Ascending in the bracketsCode:blabla.Sort(<your data variable>);
Obviously you can make that Descneding if that's what you need.Code:blabla.Sort(<your data variable>, Ascending);
Thanks for your reply, but i already tried that
Well I played with the actual settings of datagridcolumns instead of trying to program it, and I came across a setting that defines in what format the values in the column are. I set it to custom and typed in 00000, so what that did is that it added zeroes to the score number until the number had 5 digits (e.g. 00035). When I sorted the column in that format it finally did what I wanted
Soo... if anybody has the same problem do it like that
Still, thanks for your reply.
So you decided too try your best to not actually have to do any programming? Seriously?
Well..... Yeah!
I never thought of just playing with the settings in the designer...![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks