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

Problem in adding items in RadToolStrip

2 Answers 73 Views
CommandBar
This is a migrated thread and some comments may be shown as answers.
Faizullah Khan
Top achievements
Rank 1
Faizullah Khan asked on 11 Oct 2011, 02:07 PM
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 Answers, 1 is accepted

Sort by
0
Faizullah Khan
Top achievements
Rank 1
answered on 12 Oct 2011, 07:52 AM
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
0
Stefan
Telerik team
answered on 14 Oct 2011, 09:35 AM
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.

Tags
CommandBar
Asked by
Faizullah Khan
Top achievements
Rank 1
Answers by
Faizullah Khan
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or