Error while adding multiple Chunks

3 posts, 0 answers
  1. Clatonh
    Clatonh avatar
    8 posts
    Member since:
    Jun 2007

    Posted 25 Jun 2007 Link to this post

    Hello everyone,

        Not sure if this has been discussed before, But I am using a code mentioned in the Help to add multiple chunks.

    Dim RadRibbonBarChunk1 As RadRibbonBarChunk = New RadRibbonBarChunk()
    Dim RadRibbonBarChunk2 As RadRibbonBarChunk = New RadRibbonBarChunk()
    Dim RadRibbonBarChunk3 As RadRibbonBarChunk = New RadRibbonBarChunk()
    RadRibbonBarChunk1.Text = "Options"
    RadRibbonBarChunk2.Text = "Text"
    RadRibbonBarChunk3.Text = "Alignment"
    Dim RadRibbonBarCommandTab1 As RadRibbonBarCommandTab = radRibbonBar1.CommandTabs(0)
    RadRibbonBarCommandTab1.Items.AddRange(New Telerik.WinControls.RadElement() { _
        RadRibbonBarChunk1, RadRibbonBarChunk2, RadRibbonBarChunk3})

    Unfortunately it gives me an Error in the above statement, 
    System.InvalidCastException was unhandled
      Message="Unable to cast object of type 'Telerik.WinControls.RadElement[]' to type 'Telerik.WinControls.RadItem[]'."

    Can someone help me to add multiple chunks or tell me what am I doing wrong here...

  2. Dwight
    Dwight avatar
    475 posts

    Posted 28 Jun 2007 Link to this post

    Hi Claton,

    There is a typo in the documentation, which will fixed for SP2. You should be creating a collection of RadItems instead of a collection of RadElements. Change your code to look like this and you should be fine:

    Dim RadRibbonBarChunk1 As RadRibbonBarChunk = New RadRibbonBarChunk() 
    Dim RadRibbonBarChunk2 As RadRibbonBarChunk = New RadRibbonBarChunk() 
    Dim RadRibbonBarChunk3 As RadRibbonBarChunk = New RadRibbonBarChunk() 
    RadRibbonBarChunk1.Text = "Options" 
    RadRibbonBarChunk2.Text = "Text" 
    RadRibbonBarChunk3.Text = "Alignment" 
    Dim RadRibbonBarCommandTab1 As RadRibbonBarCommandTab = radRibbonBar1.CommandTabs(0) 
    RadRibbonBarCommandTab1.Items.AddRange(New Telerik.WinControls.RadItem() { _ 
        RadRibbonBarChunk1, RadRibbonBarChunk2, RadRibbonBarChunk3}) 

    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. DevCraft R3 2016 release webinar banner
  4. Clatonh
    Clatonh avatar
    8 posts
    Member since:
    Jun 2007

    Posted 03 Jul 2007 Link to this post

    Thanks a lot Evtim, this solves the prb.

Back to Top