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 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,
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.