How to set the arrow button image

4 posts, 0 answers
  1. Eli
    Eli avatar
    11 posts
    Member since:
    Feb 2008

    Posted 25 Mar 2008 Link to this post

    Hi.
    I want to customize the arrow button on the dropdown control.
    What I've found so far is how to set the backcolor and the arrow color, but not how to put my own image on the button.
    How can I do it?

    Another question is how to put an image on the editor portion of the combobox (I want to display the image that appears near the text for the selected item as well).

    thanks.
  2. Kiril
    Admin
    Kiril avatar
    158 posts

    Posted 25 Mar 2008 Link to this post

    Hello Eli,

    Thank you for writing.

    You can modify the image of the RadComboBox arrow button in the following fashion. Create a new image-bearing element (called an ImagePrimitive), and add it to the ArrowButton in the RadComboBox.

    Please refer to the code below. Modify the path to the image being loaded in the ImagePrimitive to point to your own image. The border primitive which draws a border around the element it encloses, is hidden. Also, you may have to adjust the value of the PositionOffset property of the ImagePrimitive in order to position it as you would like. You can make fine modifications to the appearance and layout of the controls at runtime using the RadControlSpyForm.

                //create the image child  
                RadComboBoxElement comboboxElement = radComboBox1.RootElement.Children[0] as RadComboBoxElement;  
                ImagePrimitive ip = new ImagePrimitive();  
                ip.Image = Image.FromFile("C:\\b.bmp");  
                //hide the border  
                ((RadArrowButtonElement)comboboxElement.Children[2].Children[1]).Children[1].Visibility = Telerik.WinControls.ElementVisibility.Collapsed;  
                  
                //add the image child  
                ((RadArrowButtonElement)comboboxElement.Children[2].Children[1]).Children.Add(ip);  
     

    In response to your second question - currently, RadComboBox does not support showing the image of the selected item. This is functionality that has been requested by other customers too, and we will consider adding it in future versions of our product.

    I hope this helps. If you have any additional questions, please contact me.

    All the best,
    Kiril
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Eli
    Eli avatar
    11 posts
    Member since:
    Feb 2008

    Posted 25 Mar 2008 Link to this post

    Thanks.
    I'll give it a try.

    Very wired that you don't have support for image on the selected item... It can be done even in System.Windows.Forms.ComboBox....

    Can I do this with custom-paint or something like that?
  5. Kiril
    Admin
    Kiril avatar
    158 posts

    Posted 25 Mar 2008 Link to this post

    Hello Eli,

    We advise against using custom-painting in this control. However, there is an option you might find useful in achieving what you're looking for. The RadComboBox text area is actually a Microsoft TextBox control, hosted within the combo box. You can modify the Microsoft TextBox to display an image within itself, using directions provided in online resources.

    I hope this helps. Please contact me if you need any further assistance.

    Sincerely yours,
    Kiril
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top