Hi
I've used the UltraComboEditor control with an ImageList to get a list of items with icons next to them. This all works fine except the images I have are 48x48 pixels. What I want the control to do is make each item in the list 48 pixels high (or thereabouts) and to display the images at native resolution. What's actually happening is that the image is getting scaled to whatever the height of the text is. If I make the text large, the images are scaled up, but I don't want large text, i just want large images.
Is this possible?
Chris
Hi Chris,
Try this:
this.ultraComboEditor1.Items.ValueList.ItemHeight = 48;
i want to do the same thing, displaying a smaller image but instead of on the list view which i get a perfect item size on the combo itself where for some reason it streatches to the combo borders...
is there a way to set the size for the selected image on the combo?
Sorry, but I do not understand your question.
is there a way to add padding on the left side of the image in the listview items?
i have an item with image and text but the image goes all the way to the left
also i need to know how to add padding between the image and the text if possible?
it goes like this...in the ultracomboeditor u have a value list, what i wanted is to have the possibility to draw the string and the image in the combo display and the itemList display with padding and a distance between the image and the text
since no simple solution was to be found i had to redraw using ValueList_DrawValueListItem which is an event in the value list.
private void ValueList_DrawValueListItem( object sender, Infragistics.Win.DrawValueListItemEventArgs e) {
ValueListItem item = e.ValueListItem as ValueListItem; Rectangle rect = e.TextAndImageAreaBounds; Rectangle paddedRect = new Rectangle(rect.X + Padding.Left, rect.Y + Padding.Top, Width - (Padding.Left + Padding.Right), Height - (Padding.Top + Padding.Bottom));
Image img = item.Appearance.Image as Image; if (img == null) { int? num = item.Appearance.Image as int?; if (num != null && num > 0 && num < comboBoxPlus1.ImageList.Images.Count) { img = comboBoxPlus1.ImageList.Images[(int)num]; } } // draw focus rect if needed if ((e.DrawItemEventArgs.State & DrawItemState.Selected) == DrawItemState.Selected) { using (SolidBrush sb = new SolidBrush(Color.White)) { e.DrawItemEventArgs.Graphics.FillRectangle(sb, rect); } }
// draw img Rectangle imgRect = Rectangle.Empty; if (img != null) { imgRect = new Rectangle(paddedRect.Left, paddedRect.Top, img.Width, img.Height); e.DrawItemEventArgs.Graphics.DrawImage(img, imgRect); }
//draw text string text = item.DisplayText; if (text != null && !string.IsNullOrEmpty(text)) { using (SolidBrush sb = new SolidBrush(e.ResolvedAppearance.ForeColor)) { Rectangle txtRect = new Rectangle(paddedRect.Left + imgRect.Width + _imgTxtDist, paddedRect.Top, paddedRect.Width - imgRect.Width - _imgTxtDist, paddedRect.Height); e.DrawItemEventArgs.Graphics.DrawString(text, e.DrawItemEventArgs.Font, sb, txtRect); } }
e.DoDefaultDrawing = false; }
i hope it will help the guy after me...
Hi,
Now I'm more confused. Are you talking about Ultracombo or ListView? Because your new post seems to be referring to ListView.
I don't think there's any way to set the padding in the UltraCombo - but you could put padding around your images by modifying the images themselves.
I'm not sure about ListView. If there is such a property, I imagine it would be on the ItemSettings properties.