簡體   English   中英

如何在列表框的項目中存儲某些文本框的值? 沒有數據庫。但是使用數組

[英]How can i store values of some text box in a item of a list box?? without a database., but by using array

我們需要將存儲textbox.text在單個項目中index.if選擇的指數的變化在文本框也應該改變.the文本

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

你可以輕松地使用JavaScript。 在下拉列表更改事件上調用programTitleChange()javascript函數。

Javascript功能:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM