Cannot Add multiple chunks programmatically

4 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. Todd Anglin
    Todd Anglin avatar
    2040 posts
    Member since:
    Aug 2005

    Posted 27 Jun 2007 Link to this post


    Sorry for the trouble. It appears the the documentation has a typo. 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}) 

    Let me know if that solves your problem.

  3. Vassil Petev
    Vassil Petev avatar
    1765 posts

    Posted 28 Jun 2007 Link to this post

    Thank you for the help, Todd. Indeed, there is a typo in the docs, which has been fixed. The new version of the documentation will be available with SP2.

    Sincerely yours,
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  4. Clatonh
    Clatonh avatar
    8 posts
    Member since:
    Jun 2007

    Posted 03 Jul 2007 Link to this post

    Thanks a lot Todd, this solves the prb.



Back to Top