以其他形式阅读字典 [英] Reading dictionaries in other forms
问题描述
Form1
中,我想读到一个列表框上另一种形式完全是希望能够使用按钮添加和删除条目。最好的方法是什么?真的来了这里。 使用Visual Basic 2015与Windows窗体应用程序。
提前感谢! / p>
这是我想在另一种形式的列表框上阅读的提到的字典。
公共类Form1
Dim userLog As New Dictionary(Of String,String)
私有子Form1_Load(发件人作为对象,e作为EventArgs)处理MyBase.Load
userLog(one)=aaa
userLog(two)=aaa
userLog(three)=aaa
End Sub
创建公共属性而不是私有变量
公共属性userLog作为新字典(String,String)
您可以使用 Form1.userLog
Novice VB user here. Hope I haven't been staring the answer in the eye for the past day or so but I have a made a dictionary in Form1
that I would like to read onto a listbox on another form entirely with the hopes of being able to add and remove the entries with buttons. What is the best method to go about this? Have really come stuck here.
Using Visual Basic 2015 with Windows Form Application.
Thanks in advance!
This is the mentioned dictionary I would like to read on a listbox on the other form.
Public Class Form1
Dim userLog As New Dictionary(Of String, String)
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
userLog("one") = "aaa"
userLog("two") = "aaa"
userLog("three") = "aaa"
End Sub
Create a public property instead of a private variable
Public Property userLog As New Dictionary(Of String, String)
You can access it from other forms using Form1.userLog
Read more in this MSDN Article
这篇关于以其他形式阅读字典的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!