如何获得Devexpress LookupEdit Value会员价值?

时间:2012-02-15 04:33:39

标签: vb.net winforms devexpress repositorylookupedit

我正在使用devexpress。 我想知道如何在lookupEdit中获取值成员值。 我将DisplayMember设置为SupplierName之前 和ValueMember到SupplierID

下面的代码同时显示了两个和SupplierName作为lookupedit中的文本。 我想要的是将SupplierName保持为显示,但我想在将它保存到数据库时获取supplierID

情景:

  

我想要供应商ID的值,例如001 - Supplier1 The   在查找中显示文本是Supplier1我想要的是001

 Private Function LoadSupplierData()
    Dim bResult As Boolean
    Dim SQLcmd As New System.Text.StringBuilder
    SQLcmd.AppendLine("SELECT SupplierID,SupplierName ")
    SQLcmd.AppendLine("FROM Supplier ")
    SQLcmd.AppendLine("WHERE Status='Active'")
    Try
        Using SQLconnect As New SqlConnection(g_constring)
            Using SQLadapter As New SqlDataAdapter(SQLcmd.ToString, SQLconnect)
                Dim ds As New DataSet
                SQLadapter.Fill(ds, "SupplierDetails")
                Dim dvm As DataViewManager = New DataViewManager(ds)
                dvMain = dvm.CreateDataView(ds.Tables("SupplierDetails"))
            End Using
        End Using
        txtSupplier.Properties.DataSource = dvMain
     Catch ex As Exception
        MessageBox.Show(ex.Message.Trim, "Error in database", MessageBoxButtons.OK, MessageBoxIcon.Stop)
        bResult = False
    End Try
    Return bResult
End Function

1 个答案:

答案 0 :(得分:5)

要获取所选值,您只需执行txtSupplier.EditValue

即可