Hello,,
I'm reposting this question again, hope to get solution soon.
For the below four comboBoxes implementation, I need to turn TextBox Visibility to true Only if I selected the Item = "ID" from any comboBox. This code works fine, but the the textbox will be invisible if I selected any other item from the other comboBoxes..
For example: If I selected "ID" from ComboBox2, then texBox will be visible beside comboBox2 (But I still need this to be visible even if I select some other items from the other three comboBoxes
So, The textbox is invisible by default, and if "ID" is not selected from any comboBox, textbox will remain invisible. If it's being selected from any of comboBoxes, it will remain visible but only beside the comboBox.
Hope to check my code below and let me know what to add/change. I think a function will be a good idea so that I can call it in each comboBox
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{if (comboBox1.SelectedItem == "ID")
{
TextBox1.Visible = true;
TextBox1.Location = new System.Drawing.Point (31, 59);
}
else
{
TextBox1.Visible = false;
}
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
{if (comboBox2.SelectedItem == "ID")
{
TextBox1.Visible = true;
TextBox1.Location = new System.Drawing.Point (31, 91);
}
else
{
TextBox1.Visible = false;
}
private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
{if (comboBox3.SelectedItem == "ID")
{
TextBox1.Visible = true;
TextBox1.Location = new System.Drawing.Point (31, 122);
}
else
{
TextBox1.Visible = false;
}
private void comboBox4_SelectedIndexChanged(object sender, EventArgs e)
{if (comboBox4.SelectedItem == "ID")
{
TextBox1.Visible = true;
TextBox1.Location = new System.Drawing.Point (31, 150);
}
else
{
TextBox1.Visible = false;
}
Suthish NairPosted Sep 11, 2013, 9:05 AM
Sanjeeb LenkaPosted Sep 11, 2013, 5:26 AM
but it is not possible to show same text box in different places at a time.
Hind NajimPosted Sep 11, 2013, 5:11 AM
I think there is some confusion here. I'm not checking the comboBox if it's checked or not. I'm trying to check which item that I select from each comboBox (I mean from which comboBox I selected the "ID" item.
If I selected Text "ID" from ComboBox1 then text box will be shown beside comboBox1 and it will be still shown even if I tried to select some other items from the other comboBoxes.
If I selected "ID" Item from comboBox3, then the textBox will be shown only beside comboBox3 and it will be shown / visible even if I select another items from ComboBox4 or comboBox2 or comboBox1.
The reason that I don't want to add another textboxes because I'm storing the textbox value to an array and pass it as a parameter to another function.
Hope I did explain the problem. It would be nice to get useful help on this from you guys
Sanjeeb LenkaPosted Sep 11, 2013, 3:08 AM
As i saw your code you are showing one textbox (Textbox1) if the combobox is selected.
consider a scenario if all the combobox are selected then where you will show the textbox as you have only one textbox. From my side place one one textbox for each combobox and make visible false true as you required.
Hind NajimPosted Sep 11, 2013, 3:04 AM
Sorry, but Cavas control is inactive / disabled and I cannot drag it and drop it.
Maybe because I'm using Windows form application?
What to do?
Pavan RamamurthyPosted Sep 11, 2013, 2:40 AM
Hind NajimPosted Sep 11, 2013, 1:59 AM
Sorry, but still I don't understand, I;m still beginner in coding, and don't know what is Canvas used for. Is it to binding controls? and, you provided the code for first comboBox, do I need to code also the other remaining comboBoxes, (same way)?
Pavan RamamurthyPosted Sep 11, 2013, 1:34 AM