Get Selected Value Only

3 posts, 0 answers
  1. Jim
    Jim avatar
    15 posts
    Member since:
    Oct 2012

    Posted 20 May 2014 Link to this post

    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. Jim
    Jim avatar
    15 posts
    Member since:
    Oct 2012

    Posted 21 May 2014 Link to this post

    This works for me.
    AddHandler Me.McomboServices.EditorControl.CellClick, AddressOf McomboServices_CellClick
  3. DevCraft banner
  4. Dess
    Dess avatar
    1561 posts

    Posted 23 May 2014 Link to this post

    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
        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.

    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.
Back to Top