We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

GridControl combobox

I know that I can use:

Me.GridControl1.ColStyles(1).DataSource = ' A DS
Me.GridControl1.ColStyles(1).DisplayMember = "" ' A column in the DS
Me.GridControl1.ColStyles(1).ValueMember = "" ' Another column in the DS

To get a combobox on my GC to display text but save other values (numbers) to the database. This works perfectly.

But is it possible to have "DisplayMember" and "ValueMember" if I don't have a DataSource?

For example, if I have a StringCollection with "Yes", "No" and "Maybe". But I want it to save the values "1", "2" or "3" to the database and not "Yes", "No" or "Maybe".


2 Replies

MP Markus Persson January 20, 2009 12:20 PM UTC

I solved my problem by creating a DataTable:

Dim dt As DataTable = New DataTable()
Dim dr As DataRow

dt.Columns.Add(New DataColumn("Value", Type.GetType("System.String")))
dt.Columns.Add(New DataColumn("Display", Type.GetType("System.String")))

dr = dt.NewRow()
dr("Value") = "1"
dr("Display") = "Yes"
dt.Rows.Add(dr)
dr = dt.NewRow()
dr("Value") = "2"
dr("Display") = "No"
dt.Rows.Add(dr)
dr = dt.NewRow()
dr("Value") = "3"
dr("Display") = "Maybe"
dt.Rows.Add(dr)

Me.GridControl1.ColStyles(1).DataSource = dt Me.GridControl1.ColStyles(1).DisplayMember = "Display" Me.GridControl1.ColStyles(1).ValueMember = "Value"



NA Nisha Arockiya A Syncfusion Team January 20, 2009 01:31 PM UTC

Hi Markus,

Thanks for sharing information with us.

Please let us know any other concerns.

Regards,
Nisha.


Loader.
Live Chat Icon For mobile
Up arrow icon