从第二个表单上的列表框复制 [英] Copying from a listbox on a second form

查看:84
本文介绍了从第二个表单上的列表框复制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目有一个带有列表框的主窗体和一个调用带有列表框的其他窗体的菜单项.我希望能够在第二个列表框中选择一个项目,然后双击将其添加到主窗体的列表框中.

我无法使它正常工作,我想知道这是否是模态"的事情吗?

My project has the Main Form with a listbox and a menu item that calls up another form with a listbox. I wanted to be able to select an item in the second listbox and by double clicking add it to the listbox on the main form.

I can''t get this to work and I wondered if it was a "Modal" thing?

推荐答案

尝试一下

Try This

Private Sub Listbox1_DoubleClick(Byval sender as Object, Byval e as system.eventargs) Handles Listbox1.DoubleClick
''Check for selected item
If Not listbox1.SelectedItem = Nothing Then
''add it

form1.listbox2.items.add(listbox1.selecteditem)
Else

''if user did not select item, notify them
MsgBox("Please double click an item from the list.", MsgBoxStyle.OkOnly,"Please Select An Item")
Return
End If

End Sub



参数
listbox1 =第二种形式的列表框
listbox2 =主窗体上的列表框
form1 =第二种形式

祝您编程愉快:-)



Parameters
listbox1 = the list box on the second form
listbox2 = the list box on your main form
form1 = the second form

Good Luck in your programming :-)


这篇关于从第二个表单上的列表框复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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