简体   繁体   English

C#多个组合框并显示其值

[英]C# Multiple Combo Boxes and displaying their values

I am trying to create a program for a sports game online to list the potential players you can acquire from each team and their maximum stats that can be reached after leveling them up. 我正在尝试为在线体育游戏创建一个程序,以列出可以从每个团队获得的潜在球员,以及在升级他们之后可以达到的最大统计数据。

Long story short I am trying to use multiple combo boxes in MS Visual '12 (User selects team from one combo box, then one of the 5 ratings from in-game, and lastly the player from that team and rating). 长话短说,我试图在MS Visual '12中使用多个组合框(用户从一个组合框中选择团队,然后从游戏中的5个评分中选择一个,最后从该团队和评分中选择玩家)。 Once its all selected I would have a text box displaying their maximum stats. 一旦全部选中,我将有一个显示其最大统计信息的文本框。 How would I be able to do this? 我将如何做到这一点?

There are quite a few ways one could accomplish this. 一个人可以通过多种方式完成此任务。 If you have multiple contributors to there stats (for example, a batting average, and the speed they can run) you could assign number values to each option which might look something like this: 如果您对该统计有多个贡献者(例如,击球平均值以及他们的运行速度),则可以为每个选项分配数字值,如下所示:

if (comboBoxRBIs.Text == 23){
RBI = 23; //Make a variable called RBI for the player(s) and assign it a value.
}

Then consider you asked how to display that, just use something similar to: 然后考虑问您如何显示它,只需使用类似以下内容的东西:

label1.Text = RBI; //This will display how many RBI's that player has.

You could then expand on this by using a rich text box (to have more text display easier in my opinion) or if you want it to display all their stats in one area, do something similar to: 然后,您可以使用富文本框来扩展此功能(以使我更容易显示更多文本),或者如果您希望它在一个区域中显示其所有统计信息,请执行以下操作:

// playerName. RBI, and speed are all variables you assign with the comboBoxes.
label1.Text = "Player" + playerName + EnvironmentNewLine() + "RBI's" + RBI + 
EnvironmentNewLine() + "Player" + playerName + EnvironmentNewLine() + "Player Speed" + 
speed; //EnvironmentNewLine() sets the text to the next line

I hope this helped, and if I did not answer you question well please let me know and ill try to be of more assistance :). 希望这对您有所帮助,如果我没有很好地回答您的问题,请让我知道,请尽力提供更多帮助:)。 Good luck with your program! 祝您程序顺利!

RE-REPLY: RE-答复:

Okay that's fairly simple try something like this: 好的,这很简单,请尝试如下操作:

if (comboBoxPlayer.Text == "Babe Ruth")
{ 
comboBoxRating.Text = "Rating"; 
}

//Then make the last comboBox change the text of the label do something like this: //然后使最后一个comboBox更改标签的文本,如下所示:

//comboBox3 is whatever you want to call the last combobox 

if (comboBox3.TextLength != 0){
label1.Text = "Your text or variables";
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM