Change selectedItem in SelectedIndexChanged event

6 posts, 0 answers
  1. QuizzBox
    QuizzBox avatar
    46 posts
    Member since:
    Jan 2011

    Posted 06 Oct 2015 Link to this post

    Hey,

    I want to change the selected item selected by the user by an another item.

    I put the following code, but the selected item is not changed :/

    Private Sub myCombo_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles myCombo.SelectedIndexChanged​

                    ​myCombo.EditorControl.CurrentRow = myCombo.EditorControl.Rows(myNumRow)
                    myCombo.EditorControl.CurrentRow.IsSelected = True
                    myCombo.EditorControl.CurrentRow.IsCurrent = True

    End sub

    Do you have an idea pls ?

    NB : I'm on Q1 2015

  2. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 07 Oct 2015 Link to this post

    Hello Nermond,

    Thank you for writing.

    You can directly set the selected index. For example:
    Private Sub radMultiColumnComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
        If radMultiColumnComboBox1.SelectedIndex <> 2 Then
            radMultiColumnComboBox1.SelectedIndex = 2
        End If
    End Sub

    Please let me know if there is something else I can help you with. 
     
    Regards,
    Dimitar
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WinForms is Visual Studio 2017 Ready
  4. QuizzBox
    QuizzBox avatar
    46 posts
    Member since:
    Jan 2011

    Posted 08 Oct 2015 in reply to Dimitar Link to this post

    Thanks for your reply.

    Your code works on a blank project but not on mine :/

    Maybe, i'm using too many events on this control + a lightVisualElement.

    I'll continue to investigate :)

     

  5. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 09 Oct 2015 Link to this post

    Hello Nermond,

    Take all the time you need to examine this and do not hesitate to contact us if you need further assistance.

    Regards,
    Dimitar
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. QuizzBox
    QuizzBox avatar
    46 posts
    Member since:
    Jan 2011

    Posted 09 Oct 2015 Link to this post

    In fact, i wanted to cancel the selection of my item on a certain condition.

        Private Sub cmyCombo_CurrentRowChanging(ByVal sender As Object, ByVal e As CurrentRowChangingEventArgs) Handles myCombo.EditorControl.CurrentRowChanging
            If Not e.NewRow Is Nothing AndAlso e.NewRow.Cells(​Nom).Value = "" Then
                e.Cancel = True
    myCombo.MultiColumnComboBoxElement.ClosePopup()
            End If

        End Sub

    This code works :)

  7. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 12 Oct 2015 Link to this post

    Hi Nermond,

    I am glad that you have fond a solution for your case. Let us know if you have any other questions.

    Regards,
    Dimitar
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for WinForms is Visual Studio 2017 Ready