Public Property [Name]() As Integer
Get
Return ds_DriverList.Tables("ds").Rows(ListViewDriver.SelectedItems.Item(0).Index)("DriverName")
End Get
Set(ByVal Value As Integer)
End Set
End Property
Public Property [ID]() As Integer
Get
Return ds_DriverList.Tables("ds").Rows(ListViewDriver.SelectedItems.Item(0).Index)("DriverID")
End Get
Set(ByVal Value As Integer)
End Set
End Property
我想从窗口表单同时返回姓名和ID。如何做到这一点? p / s:如果只返回ID,那是有效的,但我想返回多值
Public Structure NameID
Public Name As String
Public ID As Integer
End Structure
Public Property ID() As NameID
Get
Return New NameID With {.Name = ds_DriverList.Tables("ds").Rows(ListViewDriver.SelectedItems.Item(0).Index)("DriverName"), .ID = ds_DriverList.Tables("ds").Rows(ListViewDriver.SelectedItems.Item(0).Index)("DriverID")}
End Get
Set(ByVal Value As NameID)
End Set
End Property
这是返回值。错了...
MsgBox(f.ID.ToString())
这就是我得到返回值的方式
答案 0 :(得分:0)
这是你想要的吗?
Public Structure NameID
Public Name As String
Public ID As Integer
End Structure
Public Property NameID() As NameID
Get
Return New NameID with {.Name = ds_DriverList.Tables("ds").Rows(ListViewDriver.SelectedItems.Item(0).Index)("DriverName"), .ID = ds_DriverList.Tables("ds").Rows(ListViewDriver.SelectedItems.Item(0).Index)("DriverID") }
End Get
Set(ByVal Value As NameID)
End Set
End Property
答案 1 :(得分:0)
Public ReadOnly Property [DriverName]() As String
Get
Return ds_DriverList.Tables("ds").Rows(ListViewDriver.SelectedItems.Item(0).Index)("DriverName")
End Get
End Property
Public ReadOnly Property [DriverID]() As String
Get
Return ds_DriverList.Tables("ds").Rows(ListViewDriver.SelectedItems.Item(0).Index)("DriverID")
End Get
End Property
如何调用获取表单返回
Dim f As New DriverListForm
If f.ShowDialog() = DialogResult.OK Then
MsgBox(f.DriverID.ToString + " " + f.DriverName.ToString)
Else
MsgBox("Cancelled")
End If
f.Dispose()