Jump to content

Problems with listing high scores

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
yash

yash

    Newbie

  • Members
  • Pip
  • 3 posts
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:thumbup1:), then i put all the scores from the .txt file into a datagrid (check:thumbup1:), and finaly i tried to sort them acording to the score (collumn "Score") (FAILURE!:thumbdown:). Because when I use the sort command it sorts everything by the first digit.:confused:
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:mad:).

I'm trying to make this work for some time now but just have no luck with it.:sleep:
I would be more than happy if somebody helped me out (with a solution or another way to do the whole scoring thing).:crying:

#2
Golradir

Golradir

    Newbie

  • Members
  • Pip
  • 3 posts
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 have
blabla.Sort(<your data variable>);
add , Ascending in the brackets
blabla.Sort(<your data variable>, Ascending);

Obviously you can make that Descneding if that's what you need.

#3
yash

yash

    Newbie

  • Members
  • Pip
  • 3 posts
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 :D
Still, thanks for your reply.

#4
Golradir

Golradir

    Newbie

  • Members
  • Pip
  • 3 posts
So you decided too try your best to not actually have to do any programming? Seriously?

#5
yash

yash

    Newbie

  • Members
  • Pip
  • 3 posts
Well..... Yeah! :D
I never thought of just playing with the settings in the designer...:P