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

Displaying one value and showing another in a ComboBox

I am trying to use a combobox to display one value but save another using the example in the documentation...


Private Sub Form1_Load(sender As Object, e As System.EventArgs)
Me.gridDataBoundGrid1.DataSource = PrimaryTable
Me.gridDataBoundGrid1.EnableAddNew = False

Dim gbc As GridBoundColumn = Me.gridDataBoundGrid1.Binder.InternalColumns(1)
gbc.StyleInfo.CellType = "ComboBox"
gbc.StyleInfo.DataSource = ForeignKeyTable
gbc.StyleInfo.DisplayMember = "Name"
gbc.StyleInfo.ValueMember = "CustID"
gbc.StyleInfo.ShowButtons = GridShowButtons.ShowCurrentRow
gbc.StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Left
End Sub

The combobox works as long as there is a match with a match against the "DisplayMember." When there isn't a match, the grid adds the entered text to the foreign key column of the PrimaryTable which is not desired. Is there a property I can check or an event that is raised in the later situation. Also, is there a way to make a combobox both editable and autocomplete at the same time.

2 Replies

AD Administrator Syncfusion Team February 14, 2007 05:59 PM UTC

Hi Marc,

Here is a forum that discuss with the simillar issue.
http://www.syncfusion.com/support/forums/message.aspx?MessageID=49800

Best regards,
Haneef


AD Administrator Syncfusion Team February 14, 2007 07:04 PM UTC

The forum you mentioned addresses the autocomplete problem not the other. I will re-emplain.

When the combobox "displaymember" matches the entered text, it adds the corresponding "valuemember" to the corresponding column in the the grid. This is the expected behavior.

When the combobox's "displaymember" does NOT match the entered text, there isn't a "valuemember." The combobox adds the "displaymember" instead but the datasource of the grid is expecting a foreign key. The datasource errors (unless the entered text is a foreign key).

Is their a way to find out before the combobox writes the value to the grids datasource?

Loader.
Live Chat Icon For mobile
Up arrow icon