SplitButton - Text Property

2 posts, 0 answers
  1. Ahmuser
    Ahmuser avatar
    11 posts
    Member since:
    Jun 2010

    Posted 08 Jun 2011 Link to this post

    I have used a SplitButton with two menu items on my form.  The menuitems are two - RadMenuItem1 has a text property "Ver 1" and RadMenuItem2 has a text propery "Ver 2" 
    (The togglebutton is not an option as I will have some other forms which may have more than two menu items).
    The problem is when I select the option Ver 2 the code for "Ver 1" is executing and vice versa.
    Placing a messagebox shows the problem.

    Please help.

    I use the following code:
       Private Sub RadMenuItem1_Click(sender As Object, e As System.EventArgs) Handles RadMenuItem1.Click
            'SetDefaultItem(RadMenuItem1)
            Me.RadSplitButton1.Text = "Ver 1"
        End Sub


        Private Sub RadMenuItem2_Click(sender As Object, e As System.EventArgs) Handles RadMenuItem2.Click
            'SetDefaultItem(RadMenuItem2)
            Me.RadSplitButton1.Text = "Ver 2"
        End Sub


        Private Sub RadSplitButton1_TextChanged(sender As Object, e As System.EventArgs) Handles RadSplitButton1.TextChanged
            Dim part As String = Me.RadSplitButton1.Text

    MsgBox(part)  'you will see the error here

            Select Case part       'Me.RadSplitButton1.Text


                Case "Part 1"
                    Me.BOOKS2BindingSource.Filter = "VERSION = 'V1'"
                    Me.RadPageViewPage1.Item.Visibility = ElementVisibility.Visible
                    Me.RadPageView1.SelectedPage = Me.RadPageViewPage1


                Case "Part 2"
                    Me.BOOKS2BindingSource.Filter = "VERSION = 'V2'"
                    Me.RadPageViewPage1.Item.Visibility = ElementVisibility.Hidden
                    Me.RadPageView1.SelectedPage = Me.RadPageViewPage2


            End Select






        End Sub
  2. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 13 Jun 2011 Link to this post

    Hello Ahmuser,

    Thank you for writing.

    I am writing to confirm that the TextChanged event of the control is actually fired before the text is changed. I have logged this issue into our Public Issue Tracking System and we will address it in a future release. Feel free to follow this link, where you can add your vote for this issue, and also you can subscribe for its status updates.

    Your Telerik points have been updated for this report.

    In the meantime, you can work around this by subscribing to the TextChanged event of the ActionButton:
    Public Sub New()
        InitializeComponent()
     
        AddHandler RadSplitButton1.DropDownButtonElement.ActionButton.TextChanged, AddressOf ActionButton_TextChanged
    End Sub
     
    Private Sub ActionButton_TextChanged(ByVal sender As Object, ByVal e As EventArgs)
        Dim part As String = Me.RadSplitButton1.Text
            MsgBox(part)  'you will see the error here
            Select Case part       'Me.RadSplitButton1.Text
                Case "Part 1"
                    Me.BOOKS2BindingSource.Filter = "VERSION = 'V1'"
                    Me.RadPageViewPage1.Item.Visibility = ElementVisibility.Visible
                    Me.RadPageView1.SelectedPage = Me.RadPageViewPage1
                Case "Part 2"
                    Me.BOOKS2BindingSource.Filter = "VERSION = 'V2'"
                    Me.RadPageViewPage1.Item.Visibility = ElementVisibility.Hidden
                    Me.RadPageView1.SelectedPage = Me.RadPageViewPage2
            End Select
    End Sub

    Another possible approach is to spread your logic in the appropriate RadMenuItem1 and RadMenuItem2 click event handlers:
    Private Sub RadMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadMenuItem1.Click
           'SetDefaultItem(RadMenuItem1)
           Me.RadSplitButton1.Text = "Ver 1"
           Me.BOOKS2BindingSource.Filter = "VERSION = 'V1'"
           Me.RadPageViewPage1.Item.Visibility = ElementVisibility.Visible
           Me.RadPageView1.SelectedPage = Me.RadPageViewPage1
       End Sub
     
       Private Sub RadMenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadMenuItem2.Click
           'SetDefaultItem(RadMenuItem2)
           Me.RadSplitButton1.Text = "Ver 2"
           Me.BOOKS2BindingSource.Filter = "VERSION = 'V2'"
           Me.RadPageViewPage1.Item.Visibility = ElementVisibility.Hidden
           Me.RadPageView1.SelectedPage = Me.RadPageViewPage2
       End Sub

    I hope the provided information addresses your question.

    A bit off topic, I would like to remind you that in order to continue receiving support from us, you will have to provide us with the requested information in thread "Multiline RadListControl", or take one of the steps described there. You can find this thread in Your Account.

    I am looking forward to your reply.
     
    All the best,
    Stefan
    the Telerik team
    Q1’11 SP1 of RadControls for WinForms is available for download; also available is the Q2'11 Roadmap for Telerik Windows Forms controls.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top