I'm a novice looking to learn by doing - i'm writing a small windows form app which will display various text output based on the selection from a dropdownbox
I have searched for how to do this but so far I've not found an answer. I simply want the IOPS.text value to display in a text box, based on what value has been selected from the combobox
What I have so far is this:
private void comboBox1_SelectedIndexChanged_1(object sender, EventArgs e)
{
//Insert values for block size
{
comboBox1.SelectedValue = ("4Kb");
ShowIOPS.Text = ("4096");
}
{ comboBox1.SelectedValue = ("8Kb");
ShowIOPS.Text = ("8192");
}
{
comboBox1.SelectedValue = ("16Kb");
ShowIOPS.Text = ("16384");
}
{
comboBox1.SelectedValue = ("32Kb");
ShowIOPS.Text = ("32768");
}
{ comboBox1.SelectedValue = ("64Kb");
ShowIOPS.Text = ("65536"); }
Whats happening now is that no matter what combobox value is selected, it displays the botom iops.text value in the textbox
I'm sure I've missed something very very simple and obvious, but any help would be greatly appreciated!
Try Like this...
if (comboBox1.SelectedItem.ToString() == "4Kb")
{
ShowIOPS.Text = ("4096");
}
else if (comboBox1.SelectedItem.ToString() == "8Kb")
{
ShowIOPS.Text = ("8192");
}
else if (comboBox1.SelectedItem.ToString() == "16Kb")
{
ShowIOPS.Text = ("16384");
}
else if (comboBox1.SelectedItem.ToString() == "32Kb")
{
ShowIOPS.Text = ("32768");
}
else
{
ShowIOPS.Text = ("65536");
}