Problem in adding items in RadToolStrip

3 posts, 0 answers
  1. Faizullah Khan
    Faizullah Khan avatar
    2 posts
    Member since:
    Feb 2009

    Posted 11 Oct 2011 Link to this post

    Hi Telerik team,

    I am using an older version of Telerik (Telerik RadControls for WinForms Q3 2008 Sp2) in which command bar was named as ToolStrip (i think so).

    I am facing an issue and stuck here. Can you please guide me here.

    Basically i am adding ToolStripItem on ToolStrip using following code.

    My sample code is as follows.

     

     

    Private Sub AddItem(ByVal Pi_Index As Integer)
      
        Dim lObj_TStripElement As RadToolStripElement = New RadToolStripElement
        Dim lObj_TStripItem As RadToolStripItem = New RadToolStripItem
       
        Try 
            Try 
                 lObj_TStripElement = TStripTop.Items(Pi_Index)
             Catch ex As ArgumentOutOfRangeException
                 TStripTop.Items.Add(lObj_TStripElement)
         Finally 
             lObj_TStripElement.Items.Add(lObj_TStripItem)
         End Try 
         Catch ex As Exception
             MessageBox.Show("An unexpected error encountered " & Environment.NewLine & ex.Message())
      
     End Try
    End Sub

    Now if i call AddItem by giving it index in sequence then it implementation is fine. e.g.
    call AddItem(0)
    call AddItem(1)
    call AddItem(2)

    But if sequence of index changed then items/elements are not adding in provided sequence i.e.

    AddItem(3)

    AddItem(0)

    AddItem(2)

    AddItem(4)

    AddItem(1)


    Please note that i cannot send index in sequence. How i can add items in sequence using above method?

    Thanks
  2. Faizullah Khan
    Faizullah Khan avatar
    2 posts
    Member since:
    Feb 2009

    Posted 12 Oct 2011 Link to this post

    Problem solved as under:

    Private Sub AddItem(ByVal Pi_Index As Integer)
      
        Dim lObj_TStripElement As RadToolStripElement = New RadToolStripElement()
        Dim lObj_TStripItem As RadToolStripItem = New RadToolStripItem
      
        Try
          Try
            lObj_TStripElement = TStripTop.Items(Pi_Index)
          Catch ex As ArgumentOutOfRangeException
      
            If Pi_Index <= TStripTop.Items.Count Then
              TStripTop.Items.Add(lObj_TStripElement)
            Else
              For i As Integer = TStripTop.Items.Count To Pi_Index
                lObj_TStripElement = New RadToolStripElement()
                TStripTop.Items.Add(lObj_TStripElement)
              Next
            End If
          Finally
            lObj_TStripElement.Items.Add(lObj_TStripItem)
          End Try
      
        Catch ex As Exception
          MessageBox.Show("An unexpected error encountered " & Environment.NewLine & ex.Message())
        End Try
      
      End Sub
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 14 Oct 2011 Link to this post

    Hello Faizullah,

    Thank you for writing.

    I am glad to hear that you have solved your issue. Please note that RadToolStrip is an obsolete control an it will be removed from our suite soon. This is why I highly recommend upgrading to our latest version and use RadCommandBar instead (the successor of RadToolStrip). 

    A bit off topic, I would like to remind you that your subscription package has expired, which means that you are not entitled to support services. I would highly recommend upgrading your license to the latest version in order to continue getting product updates and uninterrupted support services. Please, contact sales@telerik.com or visit your account for your upgrading options.
     
    All the best,
    Stefan
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

Back to Top