Click here to Skip to main content
15,867,895 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a combobox and three text box. In my combobox i have values from "A to L". when i select each value in combobox for example "A" I will add the values in three text boxes. How can i call the values i entered in text boxes each time from "A to L" . The text box has to clear when i select the comobooptipn "B" "C"..

What I have tried:

i have used if statement but the previous value is not displayed.

if (comboBox5.SelectedIndex == 0)
           {

               xmlWriter.WriteStartElement("A");
               xmlWriter.WriteStartElement("Amplitude");
               xmlWriter.WriteString(textBox17.Text);
               //xmlWriter.WriteString(textBox7.Text);
               xmlWriter.WriteEndElement();

               xmlWriter.WriteStartElement("Frequency");
               xmlWriter.WriteString(textBox18.Text);
               xmlWriter.WriteEndElement();

               xmlWriter.WriteStartElement("Duration");
               xmlWriter.WriteString(textBox19.Text);
               xmlWriter.WriteEndElement();

               xmlWriter.WriteEndElement();
           }

           else if (comboBox5.SelectedIndex == 1)
           {

               xmlWriter.WriteStartElement("B");
               xmlWriter.WriteStartElement("Amplitude");
               xmlWriter.WriteString(textBox17.Text);
               //xmlWriter.WriteString(textBox7.Text);

}
Posted
Updated 12-Jun-17 21:50pm
v2
Comments
Richard MacCutchan 13-Jun-17 3:54am    
Your question is not clear as to what the problem is. And using names like comboBox5 and textBox18 for your controls is a bad idea; use proper descriptive and meaningful names.
Member 13153191 13-Jun-17 3:59am    
sorry that was an example. coming back to the question, how can i get the values from textbox with the selection on combobox selection ?
Richard MacCutchan 13-Jun-17 4:14am    
Sorry I have no more idea of what that means than your original question.
Member 13153191 13-Jun-17 4:39am    
I have a combobox which is having 12 options in it.I select individual option and enter a value in text box
for example option "A" ; text box value=10
option "B" ; text box value=20

how can i do this with the code when i select option "B" the "A" value gets reset. That is the problem. Thank you for you're time
Richard MacCutchan 13-Jun-17 4:46am    

string option = combobox.SelectedItem;
switch (option)
{
case 'A':
textbox.Text = "10";
break;
case 'B':
textbox.Text = "20";
break;
//... etc
}

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