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

ComboBox Multiple Selections

Hi

I have existing ComboBox's in a GridControl written in VB. I now want to enable multiple selections within the ComboBox using the CTRL key. I then need to store the selected rows of the ComboBox into a field in a table. Any help you might offer would be appreciated.


1 Reply

SR Sri Rajan Syncfusion Team June 30, 2008 01:21 PM UTC

Hi Ed,

Thank you for your interest in Syncfusion products.

Combobox does not support multiple selection. But you can achieve this by hiding the default dropdown which is displayed when dropdown button in the ComboBox is clicked. Then showing the listbox for multiple selection, and display the selected items in the cell.
Please refer the below code for more details.

Private Sub l_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim cc As GridCurrentCell = Me.gridControl1.CurrentCell
l.Hide()
flag = 0
End Sub
Private Sub l_SelectedValueChanged(ByVal sender As Object, ByVal e As EventArgs)
Dim cc As GridCurrentCell = Me.gridControl1.CurrentCell
If (Me.gridControl1(cc.RowIndex, cc.ColIndex).CellType = "ComboBox") Then
Dim str As String = ""
For i As Integer = 0 To l.SelectedItems.Count - 1
str += l.SelectedItems.Item(i).ToString()
Next i
Me.gridControl1(cc.RowIndex, cc.ColIndex).Text = str
End If
End Sub

Private flag As Integer = 0
Private Sub gridControl1_CellButtonClicked(ByVal sender As Object, ByVal e As GridCellButtonClickedEventArgs)
l.DataSource = list
l.Height = 70
Dim x As Integer=(e.Button.Bounds.X+e.Button.Bounds.Width)-l.Width
Dim y As Integer = (e.Button.Bounds.Y + e.Button.Bounds.Width)
l.Location = New Point(x,y)
If flag = 0 Then
l.Show()
flag = 1
End If
End Sub

Private Sub gridControl1_CurrentCellShowingDropDown(ByVal sender As Object, ByVal e As GridCurrentCellShowingDropDownEventArgs)
e.Cancel = True
End Sub

Here is the minimal sample which implements this task.
http://websamples.syncfusion.com/samples/grid.windows/F74750/main.htm

Please let me know it this helps.

Best Regards,
Srirajan


Loader.
Live Chat Icon For mobile
Up arrow icon