こんにちは、 devexpress を使用しています。lookupEdit で value メンバーの値を取得する方法を知りたいです。DisplayMember を SupplierName の前に設定し、ValueMember を SupplierID に設定しました
以下のコードは、lookupedit のテキストとして両方と SupplierName を表示します。私が望むのは、SupplierName を表示として保持することですが、データベースに保存するときに、supplierID を取得したいです。
シナリオ:
たとえば 001 - Supplier1 などのサプライヤー ID の値が必要です。ルックアップの表示テキストは 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