This is a migrated thread and some comments may be shown as answers.

How to set the arrow button image

3 Answers 511 Views
ComboBox and ListBox (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Eli
Top achievements
Rank 1
Eli asked on 25 Mar 2008, 10:19 AM
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.

3 Answers, 1 is accepted

Sort by
0
Kiril
Telerik team
answered on 25 Mar 2008, 01:42 PM
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
0
Eli
Top achievements
Rank 1
answered on 25 Mar 2008, 04:07 PM
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?
0
Kiril
Telerik team
answered on 25 Mar 2008, 04:41 PM
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
Tags
ComboBox and ListBox (obsolete as of Q2 2010)
Asked by
Eli
Top achievements
Rank 1
Answers by
Kiril
Telerik team
Eli
Top achievements
Rank 1
Share this question
or