TextBox needed to be lots of text boxes
-
Hi experts, How do i go about splitting a texbox with lots of information in it to lots of little ones. Initially what i want to do is perform a sort on a textbox thus having to split the textbox up to perform the sort. The textboxe is for a high score game so if someone does well they have the option of putting their name and the program will show the high score to everyone at the end. Is there any easy way to do this then having to split up the textbox, bearing in mind that the names vary from length to length - e.g dan to Patrick.... Many thanks Dan
-
Hi experts, How do i go about splitting a texbox with lots of information in it to lots of little ones. Initially what i want to do is perform a sort on a textbox thus having to split the textbox up to perform the sort. The textboxe is for a high score game so if someone does well they have the option of putting their name and the program will show the high score to everyone at the end. Is there any easy way to do this then having to split up the textbox, bearing in mind that the names vary from length to length - e.g dan to Patrick.... Many thanks Dan
I would presume you would hold all the scores in an array, sorted by value each time a new score is added. Then show, say the top ten in the immediate text box by just filling in the top ten values from the array. I would use a Form if you wished to show all scores (or top 1000 or whatever).
------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
-
Hi experts, How do i go about splitting a texbox with lots of information in it to lots of little ones. Initially what i want to do is perform a sort on a textbox thus having to split the textbox up to perform the sort. The textboxe is for a high score game so if someone does well they have the option of putting their name and the program will show the high score to everyone at the end. Is there any easy way to do this then having to split up the textbox, bearing in mind that the names vary from length to length - e.g dan to Patrick.... Many thanks Dan
You really should be more object oriented about all this. In Your backend you should create a User class that exposes 2 properties, Name and High Score. Let your class implement the IComparable interface, and in the CompareTo function just compare the high scores. In your Front End you can create a list of as many users as you think sufficient, call list.Sort(), and use an Object DataSource to bind to a listbox (or Textboxes if you must) displaying the list in order.
-
Hi experts, How do i go about splitting a texbox with lots of information in it to lots of little ones. Initially what i want to do is perform a sort on a textbox thus having to split the textbox up to perform the sort. The textboxe is for a high score game so if someone does well they have the option of putting their name and the program will show the high score to everyone at the end. Is there any easy way to do this then having to split up the textbox, bearing in mind that the names vary from length to length - e.g dan to Patrick.... Many thanks Dan
I agree with zimvbcoder, you need a more structured approach. I suggest you create a Player class holding all relevant information; and a List<Player> holding your hall of fame. Then you can sort it; maybe this[^] will interest you. BTW: I would consider using a ListBox (with OwnerDraw mode) rather than a TextBox. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
-
I agree with zimvbcoder, you need a more structured approach. I suggest you create a Player class holding all relevant information; and a List<Player> holding your hall of fame. Then you can sort it; maybe this[^] will interest you. BTW: I would consider using a ListBox (with OwnerDraw mode) rather than a TextBox. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
Hi Luc, sorry it's off topic a bit, but I just wanted to say thanks for that article. It helped me through some problems I had a while back in implementing the IComparable Interface. Taught me all I know on the topic to be precise. Many Thanks.
-
Hi Luc, sorry it's off topic a bit, but I just wanted to say thanks for that article. It helped me through some problems I had a while back in implementing the IComparable Interface. Taught me all I know on the topic to be precise. Many Thanks.
I'm glad you liked it. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.