Click here to Skip to main content
15,891,908 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi.
I am creating a simple application that will be used to keep information about small gaming tournaments.
I have a Player class that has three prperties; name,race and id. Then I add players to a listbox.
Then I chose a tournament type from a combobox; Single-elimination, Double-elimination and Everyone playes everyone.

Now for the problem :)
First of all I want to get the single-elimination up. If you don't know how that kind of a tournament is then here is the structure: http://en.wikipedia.org/wiki/Single-elimination_tournament[^]. When I press the button "Create", I want it to layout all the players in a manner like on that wiki page. I'm not sure how I would go about doing that. I thought about creating a label for each player and then laying it out using some simple math but I want to have a textbox next to each player so I can record the wins and losses.
I am kinda clueless on how I can do this.

Does someone have an idea?
Any help greatly appreciated.
Posted
Comments
Richard MacCutchan 7-Nov-11 10:48am    
I would be surprised if there is not already a tool to do this for you. Try a Google search with some appropriate keywords, or even the CodeProject articles.
#realJSOP 7-Nov-11 10:55am    
Sounds like a homework assignment to me...
sigsand 7-Nov-11 11:52am    
Richard MacCutchan, I have tried to search google for something like this but without success. My searches: single elimination layout c#, tournament setup layout c#, and others.
John Simmons, it isn't a homework assignment. Even if it was, what would be the problem? Everyone looks to the internet for help.
Espen Harlinn, the DataGridView is not exactly wht I am looking for but i is better than nothing. I'm not sure how I could use it the way I want it to be. Could you give a short example on maybe how to layout two players and the winner of the two.
I will try to make something simple aswell using the DataGridView.
Thanks.
Richard MacCutchan 7-Nov-11 12:26pm    
I had a Google search myself but could not find a sample; I'm surprised as I would have expected someone to have already faced this issue. Perhaps everyone just uses a DataGridView adapted to their own requirements.
sigsand 7-Nov-11 13:19pm    
Here is what I have done so far. When I have added all the players to a listbox I press a button called Create and here is the code in the Click event:
int xpos = 10;
int ypos = 10;

int numberofplayers = listBoxPlayers.Items.Count;

foreach (Player player in listBoxPlayers.Items)
{
Label newLabel = new Label();
newLabel.Content = player.getName;
canvas1.Children.Add(newLabel);

TextBox newText = new TextBox();
newText.Width = 22;
canvas1.Children.Add(newText);

Canvas.SetLeft(newLabel, xpos);
Canvas.SetTop(newLabel, ypos);

Canvas.SetLeft(newText, xpos + 75);
Canvas.SetTop(newText, ypos);
ypos += 50;
}

I guess you are looking for something like the DataGridView Control[^]

Best regards
Espen Harlinn
 
Share this answer
 
Comments
thatraja 8-Nov-11 9:45am    
Probably he need more code to design this thing
5!
Espen Harlinn 8-Nov-11 10:16am    
Thank you, thatraja!
Agree with Espen. Also TableLayoutPanel[^] & FlowLayoutPanel[^] are right choices(Like DataGridView) but you need to write lot of code for your requirement.
 
Share this answer
 
Comments
Espen Harlinn 8-Nov-11 10:17am    
Good ideas :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900