Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Carousel > cast control to radcarousel

Not answered cast control to radcarousel

Feed from this thread
  • Jordi Borras avatar

    Posted on Jun 20, 2010 (permalink)

    Hi,

    I'm getting an error "cannot convert type system.windows.forms.control to telerik.wincontrols.ui.radcarousel" when I try to convert a control to a radcarousel. Basically, this is the code (some code is missing but are irrelevant for this example):

    foreach (Control control in listOfControls)
    {
        if (c.getType() == button)
            listOfNames = control.Name;

        if(c.getType() == ToolStrip)
        {
            ToolStrip t = (ToolStrip)control;                         //here I have no problem when I try to cast a control to a ToolStrip control
            foreach (ToolStripItem tsi in t.Items) {...}
        }

        if(c.getType() == RadCarousel)
        {
            RadCarousel r = (RadCarousel)control;             //here I get the error
            foreach (RadButtonElement rbe in r.Items) {...}
        }
    }


    Thanks

    Reply

  • Victor Victor admin's avatar

    Posted on Jun 23, 2010 (permalink)

    Hello Jordi Borras,

    Thank you for writing.

    You are not using the safe casting operators of C#. You need to use the "is" and "as" operators in order to safely cast from one type to another. Also, another issue with the code you posted is that you are calling GetType() on a variable named "c" and then casting a different variable named "control". Please review your code and apply the necessary modifications.

    Write again if you need further assistance.

    All the best,
    Victor
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

    Reply

  • Say Hello to Telerik's PivotGrid for ASP.NET AJAX, Silverlight, WPF and WinForms. Now packed with OLAP support.

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Carousel > cast control to radcarousel
Related resources for "cast control to radcarousel"

[ Features | Demos | Documentation | Knowledge Base | Telerik TV | Code Library | Step-by-step Tutorial | Blogs | Self-Paced Trainer ]