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

C#多个组合框并显示其值,c#,visual-studio-2012,combobox,C#,Visual Studio 2012,Combobox,我正在尝试创建一个在线体育游戏程序,列出你可以从每个球队获得的潜在球员,以及他们升级后可以达到的最大统计数据 长话短说,我试图在MS Visual'12中使用多个组合框(用户从一个组合框中选择球队,然后从游戏中的5个评级中选择一个,最后是该球队的球员和评级)。一旦全部选中,我会有一个文本框显示他们的最大统计数据。我怎样才能做到这一点呢?有很多方法可以做到这一点。如果您对这些统计数据有多个贡献者(例如,击球平均数和它们可以运行的速度),您可以为每个选项分配数值,这些数值可能如下所示: if (co

我正在尝试创建一个在线体育游戏程序,列出你可以从每个球队获得的潜在球员,以及他们升级后可以达到的最大统计数据


长话短说,我试图在MS Visual'12中使用多个组合框(用户从一个组合框中选择球队,然后从游戏中的5个评级中选择一个,最后是该球队的球员和评级)。一旦全部选中,我会有一个文本框显示他们的最大统计数据。我怎样才能做到这一点呢?

有很多方法可以做到这一点。如果您对这些统计数据有多个贡献者(例如,击球平均数和它们可以运行的速度),您可以为每个选项分配数值,这些数值可能如下所示:

if (comboBoxRBIs.Text == 23){
RBI = 23; //Make a variable called RBI for the player(s) and assign it a value.
}
if (comboBoxPlayer.Text == "Babe Ruth")
{ 
comboBoxRating.Text = "Rating"; 
}
//comboBox3 is whatever you want to call the last combobox 

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

然后考虑你如何显示它,只要使用类似的:

label1.Text = RBI; //This will display how many RBI's that player has.
// 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
然后,您可以使用富文本框对此进行扩展(在我看来,这样可以更容易地显示更多文本),或者如果您希望它在一个区域中显示其所有统计信息,请执行类似的操作:

label1.Text = RBI; //This will display how many RBI's that player has.
// 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
我希望这有帮助,如果我没有很好地回答你的问题,请让我知道,我会尽力提供更多帮助:)。祝你的节目好运

答复:

好吧,这很简单,试试这样:

if (comboBoxRBIs.Text == 23){
RBI = 23; //Make a variable called RBI for the player(s) and assign it a value.
}
if (comboBoxPlayer.Text == "Babe Ruth")
{ 
comboBoxRating.Text = "Rating"; 
}
//comboBox3 is whatever you want to call the last combobox 

if (comboBox3.TextLength != 0){
label1.Text = "Your text or variables";
}
//然后,让最后一个组合框更改标签的文本,执行如下操作:

if (comboBoxRBIs.Text == 23){
RBI = 23; //Make a variable called RBI for the player(s) and assign it a value.
}
if (comboBoxPlayer.Text == "Babe Ruth")
{ 
comboBoxRating.Text = "Rating"; 
}
//comboBox3 is whatever you want to call the last combobox 

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

请发布您遇到的代码/关于代码本身的特定问题。一些有用的信息。但我需要帮助的是组合框。例如,CountryOK,这相当简单,尝试以下操作:'code'if(comboBoxPlayer.Text==“Babe Ruth”){comboBoxRating.Text=“Rating”;}//然后要使最后一个组合框更改标签的文本,请执行以下操作://如果(comboBox3.TextLength!=0),则此组合框是您想要调用的最后一个组合框{label1.Text=//playerName.RBI和speed都是通过组合框指定的变量。label1.Text=“所需的文本或变量”;{非常感谢Steven。您的回答让我更好地理解了我需要编写的代码。:)很好,如果您有任何其他问题,请随时提问,我相信您知道或很快就会了解到,本网站有一个非常好的社区:)