0
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())
这就是我获得返回值的方式

4

2 回答 2

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
于 2013-03-30T14:23:57.830 回答
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()
于 2013-03-31T10:24:08.503 回答