I have a column of datatype bitmap. the value is composed of a set of icons merged into an image side by side which can vary in numbers. My problem is that when the column is resized the images shrink to fit to the point where no images are visible. How can I prevent this from hapenning? I'd like the image to be truncated instead of resized, only show what fit's in the cell and possibly have a "..." or similar indicator at the end to indicate that not all icons are shown.
I don't think there's any way to do this automatically. You can probably use a CreationFilter to control the size of the UIElements in the cell, though. If you are going to try that, I recommend that you get the Infragistics UIElementViewer Utility. It's a big help in working with UIElements.
This doesn'tdo the ellipsis like you wanted, but it seems to work pretty well:
public class MyCreationFilter : IUIElementCreationFilter { #region IUIElementCreationFilter Members public void AfterCreateChildElements(UIElement parent) { if (parent is EditorWithTextUIElement) { ImageUIElement imageUIElement = parent.GetDescendant(typeof(ImageUIElement)) as ImageUIElement; if (imageUIElement != null) { imageUIElement.Rect = new Rectangle( imageUIElement.Rect.X, imageUIElement.Rect.Y, imageUIElement.Image.Width, imageUIElement.Rect.Height); } } } public bool BeforeCreateChildElements(UIElement parent) { return false; } #endregion }
Hi,
It's not really a good idea to set properties on the appearance of a cell inside a CreationFilter. Setting properties like you are doing here will cause the grid's elements to get dirtied, which will cause hte CreationFilter to get called again.
Why are you setting the Image and ImageHAlign inside the CreationFilter? The InitializeRow event would be a much better place to do this. Or even using a DrawFilter and setting properties on the AppearanceData passed in, rather than the Appearance of the cell would be a much better way to go.
Also... what version of the grid are you using? I tested this out using the oldest support version (2009 Vol. 2) and the images the cell are not stretched, they are centered by default.
Hi Mike,
I have to display both image and text within my cell. In AfterCreateChildElements() I do
cellUIElement.Cell.Appearance.Image = Properties.Resources.preview_AddPreferences;
cellUIElement.Cell.Appearance.ImageHAlign =
HAlign.Left;
This works fine. However my cell's height can increase to display the text on 2 or more lines, but my image will also gets bigger and I don't want that.
I tried to do the following to reset the image to a normal size, but it didn't work.
ImageUIElement imageUIElement = parent.GetDescendant(typeof(ImageUIElement)) as ImageUIElement; if (imageUIElement != null) { imageUIElement.Rect = new Rectangle( imageUIElement.Rect.X, imageUIElement.Rect.Y, imageUIElement.Image.Width, imageUIElement.Rect.Height); }
I also tried other things like creating a new ImageUIElement and add it to the CellUIElement and then modifying EditorWithTextDisplayTextUIElement.Rect, but this didn't work as well.
Do you know why I can't resize my image or change EditorWithTextDisplayTextUIElement.Rect?
Thanks,
The above didnt work for me, if column datatype at datasource level is of type image.
if (parent is ImageUIElement)
{
ImageUIElement ImageUIElement =
parent.GetDescendant(typeof(ImageUIElement)) as ImageUIElement;
if(ImageUIElement != null)
ImageUIElement.Scaled = false;
}
Also note: if you want editor in image column , then dont set column style = image, instead set datasource column datatype as image
,otherwise it makes readonly
If you intend to show a tooltip on the ellipsis or haveit respond to a click in some way, then you are right, it's probably better to show the ellipsis as a second element - whether it be an ImageUIElement or whatever.
The ellipsis you see on text is probably just drawn as part of the text using the TextTrimming property. The GDI+ text rendering handles that automatically and that's part of the same drawing operation. That only applies to text, anyway, so tha's not what you want.
The ellipsis I was referring to is the one used by editors like UltraTextEditor. Put an UltraTextEditor control on a form and set ShowOverflowIndicator to true and then make the text longer than the control. It's not really an ellipsis, but it has a similar function. Like I said, I'm not sure how tightly tight that element is to the editors, so it might be easier for you to just use an ImageUIElement, but the OverflowIndicator might have some other useful functionality - so it might be worth looking into.
I managed to do the tooltip part with very little trouble. I used http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.Aspx?ArticleID=8644 as a starting point and used the CustomToolTipImage property. Since i only wanted to show images and no text I had to play a bit with the Title, ToolTipText and Font properties to basically only show " " as text and I set the font to a size of 0.5. That seems to work great for me soo far.
I briefly looked into the ellipsis and looked for that ellipsis button element you mentionned but have not found it. It seems like the ellipsis on the text cells is the same element as the one containing the text? I would prefer not using an image that contains an ellipsis unless a second image could be added at the end of the cell containing only the ellipsis and still have our icons showing as there own image. basically have two images on one cell instead of a modified image containing the ellipsis.