简体   繁体   English

如何在列表框的项目中存储某些文本框的值? 没有数据库。但是使用数组

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

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 我们需要将存储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;
            }

You can do it using javascript easily. 你可以轻松地使用JavaScript。 call programTitleChange() javascript function on dropdown change event. 在下拉列表更改事件上调用programTitleChange()javascript函数。

Javascript function : 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.

相关问题 尝试进行测验应用。 如何临时自动将组合框值存储在数据库中 - Attempting to Make Quiz Application. How can I temporarily automatically store combo-box values in a database 我可以使用文本框名称作为列表中的值吗? - Can i use text box names as values in a list? 从文本数组向列表框添加值 - Adding values to a list box from array WITH text 如何基于文本框值从列表框中删除项目 - How to remove an item from a list box based on a text box value 无法将空的文本框值保存到数据库。(格式为int) - Cannot save empty text box value to database.(format is in int) 将数组值放入列表框中 - Array values into list box 如何使用 Blazor 中另一个选择框的选定项更改选择框的列表元素? - How can I change the list elements of a select box with the selected item of another select box in Blazor? 如何使用列表框选择词典中的项目 - How to select a item in a Dictionary, using a list box 如何使用c#动态分配标签页并添加单个文本框以将文本框中的数据存储到数据库中 - How to assign Tab Pages dynamically and add a single text box to store the data from text box into the database using c# 如何使用组合框中的 colors 在文本框中键入时更改文本的颜色? - how can I change the color of my text while I type in the text box by using the colors in combo box?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM