有两个列表项,并且想要在添加单击时将一个项输入另一个 [英] having two list item and want to enter the item of one into another on add click

查看:86
本文介绍了有两个列表项,并且想要在添加单击时将一个项输入另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个下拉列表,其中包含管理员名称和列表项,其中包含在项目表中输入的项目.现在,我想选择5个在单击添加按钮时输入另一个列表框中的项目,并在单击删除按钮时删除.然后,当我单击按钮时,它们将分别添加到表中.例如,admin是abc,我添加了1,2,3,4,5
然后是abc 1
abc 2
abc 3
abc 4
abc 5

我该怎么做.

I have a dropdown list which contains the admin name and the list item which contain the items entered in item table . Now i want to select 5 items which entered in another list box on click of add button and remove on click of remove button. And then when i click on button they will be added seprately in table. For example , admin is abc and i added item 1,2,3,4,5
then abc 1
abc 2
abc 3
abc 4
abc 5

how can i do that .

推荐答案

假设ListBox1包含一个条目:"abc"

假设ListBox2包含五个条目:1 2 3 4 5

假定单击Button1,应将ListBox2中的每个条目追加到ListBox1中的"abc" ...以便ListBox1最终以五个条目结束,如上所示.

这是您编写代码的方式,非常简单,您将满意地知道自己确实了解您的代码,并且将来可以解决涉及ListBox项目的许多其他问题! >
1.将ListBox1中第一个条目的文本内容分配给变量.

2.清除ListBox1

3.迭代ListBox2中的项目:

一个.为每个项目创建一个新字符串,该字符串将项目的文本值附加到您在步骤1中创建的变量中的字符串.
b.插入您在步骤3a中刚创建的字符串.进入ListBox1
Assume ListBox1 contains a single entry: "abc"

Assume ListBox2 contains five entries: 1 2 3 4 5

Assume Button1, when clicked, should append each entry in ListBox2 to the "abc" in ListBox1 ... so that ListBox1 ends up with five entries as shown above.

Here''s how you can write the code, which is pretty simple, and you''ll have the satisfaction of knowing you really understand your code, and that you can solve many other problems in the future involving ListBox items !

1. assign the text contents of the first entry in ListBox1 to a variable.

2. clear ListBox1

3. iterate the items in ListBox2:

a. for each item create a new string which appends the text-value of the item to the string in variable you created in step 1.

b. insert this string you just created in step 3a. into ListBox1


这篇关于有两个列表项,并且想要在添加单击时将一个项输入另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆