且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将变量从 Windows 窗体传递到 Modal

更新时间:2023-12-06 09:27:16

添加一个公共属性 RecordID 到你的对话框窗口,然后像这样打开对话框

Add a public property RecordID to your dialog window, then open the dialog like this

Dim _propertSettings As New PropertySettingsWindow()
_propertSettings.RecordID = 15
_propertSettings.ShowDialog()

在对话框表单中,您可以简单地使用

In the dialog form you can simply access the record id with

_properties = db.property_info_by_id(RecordID).ToList   

从 .NET Framework 4.0 开始,您可以使用自动实现的属性


Starting with .NET Framework 4.0, you can use auto-implemented properties

Public Property RecordID As Integer

使用以前的版本,您必须编写

With previous versions you would have to write

Private _recordID As Integer
Property RecordID As Integer
    Get
        Return _recordID
    End Get
    Set(ByVal value As Integer)
        _recordID = value
    End Set
End Property