This is a migrated thread and some comments may be shown as answers.

Get Selected Value Only

2 Answers 44 Views
MultiColumn ComboBox
This is a migrated thread and some comments may be shown as answers.
William
Top achievements
Rank 1
William asked on 20 May 2014, 02:59 PM
I want to use this control because of the search capability. I want the user to look up an item based off its code or description. This works just fine. Once the user finds the item they want, I need to add it to a grid. This functionality works. Here is the problem. I need to get the value of what's clicked or the value when they hit enter or tab. SelectedIndexChanged fires off on everything. This causes unwanted items to be added to the grid. I only want the items added if the user clicks on it or hits tab or enter. SelectedIndexChanged fires off on up and down arrows and so on. How can I get the value of what's actually clicked? Click and mouseclick do not work because it fires off for the list box click only and not the underlying grid.
Anyone have any ideas on how to only get what the user clicks on and not ever item when SelectedIndexChanged fires?

2 Answers, 1 is accepted

Sort by
0
William
Top achievements
Rank 1
answered on 21 May 2014, 07:23 PM
This works for me.
‚Äč
AddHandler Me.McomboServices.EditorControl.CellClick, AddressOf McomboServices_CellClick
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 23 May 2014, 09:51 AM
Hello Jim,

Thank you for writing.

It is normal that the SelectedIndexChanged event fires when filtering or when navigating using the arrow keys. You actually change the selection as the current row is updated. If you requirement is to detect what row is selected only when the user clicks over it or press the Enter/Tab key, you can use the following code snippet:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Me.CustomersTableAdapter.Fill(Me.NorthwindDataSet.Customers)
 
    AddHandler Me.RadMultiColumnComboBox1.MultiColumnComboBoxElement.EditorControl.CellClick, AddressOf EditorControl_CellClick
    AddHandler Me.RadMultiColumnComboBox1.MultiColumnComboBoxElement.TextBoxElement.TextBoxItem.TextBoxControl.PreviewKeyDown, _
        AddressOf TextBoxControl_PreviewKeyDown
End Sub
 
Private Sub TextBoxControl_PreviewKeyDown(sender As Object, e As PreviewKeyDownEventArgs)
    If e.KeyCode = Keys.Tab Or e.KeyCode = Keys.Enter Then
        Dim selectedRow = Me.RadMultiColumnComboBox1.MultiColumnComboBoxElement.EditorControl.CurrentRow
    End If
End Sub
 
Private Sub EditorControl_CellClick(sender As Object, e As Telerik.WinControls.UI.GridViewCellEventArgs)
    Dim selectedRow = e.Row
End Sub

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Desislava
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
MultiColumn ComboBox
Asked by
William
Top achievements
Rank 1
Answers by
William
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or