we need to store the textbox.text
in a single item in the index.if
the selected index changes .the text in textbox should also change
private void button1_Click(object sender, EventArgs e)
{
if (listBox1.SelectedIndex == 0)
{
tb[0].Text = textBox1.Text;
tb[1].Text = textBox2.Text;
tb[2].Text = textBox3.Text;
tb[3].Text = textBox4.Text;
tb[4].Text = textBox5.Text;
}
if (listBox1.SelectedIndex == 1)
{
t[0].Text = textBox1.Text;
t[1].Text = textBox2.Text;
t[2].Text = textBox3.Text;
t[3].Text = textBox4.Text;
t[4].Text = textBox5.Text;
}
You can do it using javascript easily. call programTitleChange() javascript function on dropdown change event.
Javascript function :
function programTitleChange(elm) {
if (elm.options[elm.selectedIndex].text != "Select") {
document.getElementById('txtTitle').value =
elm.options[elm.selectedIndex].text;
document.getElementById('txtTitle').readOnly = true;
}
else {
document.getElementById('txtTitle').value = "";
document.getElementById('txtTitle').readOnly = false;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.