Images in Dropdown from Resourcefile

2 posts, 0 answers
  1. Karl Golling
    Karl Golling avatar
    226 posts
    Member since:
    Jun 2005

    Posted 17 Apr 2012 Link to this post

    Hi,
    I keep getting the Error Cannnot convert type 'object' to 'System.Drawing.Image' on the line

    element.Image = global::TelerikEditor.Properties.Resources.ResourceManager.GetObject(currCountry)

    How would I change this?

    private void LoadFlags( Telerik.WinControls.UI.RadDropDownList myDLL, Array Cntrys)
    {
        myDLL.Items.Clear();
        foreach (string currCountry in Cntrys)
        {
            RadListDataItem element = new RadListDataItem();            
            element.Text = currCountry;
            element.Image = global::TelerikEditor.Properties.Resources.ResourceManager.GetObject(currCountry);
            element.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
            myDLL.Items.Add(element);
        }
    }
  2. Karl Golling
    Karl Golling avatar
    226 posts
    Member since:
    Jun 2005

    Posted 17 Apr 2012 Link to this post

    Sorry to bother, I just figured out the correct way which is:

    element.Image = (Image)global::TelerikEditor.Properties.Resources.ResourceManager.GetObject(currCountry.ToLower());

    Karl
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top