繁体   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