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;
            }

1 Answers

0
Abhay Agarwal On

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;
        }
    }