Currently I am adding images into cells (effectively replacing the UltraValidator) but I've run into some problems with the image format and so forth.My question is: Which format does my image need to be in to be used in a cell? Dimensions? And what encoding should I use? ie) A .bmp may be saved in R5 G5 B5 or R8 G8 B8 etc
Here's a nice clear, concise image we are familiar with.
.
Here's an example of what my images appear as.. and yes I did add an alpha layer which doesn't seem to be working.
Hi,
rzabransky said:Which format does my image need to be in to be used in a cell? Dimensions? And what encoding should I use? ie) A .bmp may be saved in R5 G5 B5 or R8 G8 B8 etc
It makes no difference to the grid. If you are using a DrawPhase, then I assume that means you are using a DrawFilter and just setting the Image property on the drawParams.AppearanceData.Image property. This property is of type System.Drawing.Image. How you get that image or from what format it comes are all part of the DotNet Framework and has nothing to do with the grid.
As for Alpha channels, the last I heard, there is no support for them in the DotNet Framework. They do support transparency in an image, but once again, that's nothing to do with the grid, it's part of the Image itself. So you will need to check Microsoft's documentation for details on that. Personally, I have used the MakeTransparent method, myself, and it works well.
Regarding the size of the image, that's entirely up to you and the size (mainly the height) of your grid rows. If you want bigger images, make the grid rows bigger. If you just want to make your image fit the existing grid row, then you could use the size of the ImageUIElement as your guide.
Mike Saltzman said:It makes no difference to the grid. If you are using a DrawPhase, then I assume that means you are using a DrawFilter and just setting the Image property on the drawParams.AppearanceData.Image property.
Well, if you use a DrawFilter and just set the image on the existing ImageUIElement in the cell, then the grid will take care of several things for you:
1) It will position the element in the cell and give it a size and position.
2) Other elements, such as the Text in the cell, will be moved over to accommodate the image.
3) The ImageUIElement won't draw outside the cell.
Why are you using a DrawFilter or CreationFilter here at all? Why not simply set the Appearance on the cell?
Using a DrawFilter allows for several things to occur. - I am able to draw custom images where they are required. This includes headers, within dropdowns, etc.
- I can use it as a cycle to immediately validate user entry and display feedback.
- It allows me to attach customized tooltips to embedded UI elements. (especially editor components)
I value your suggestions, so if you can think of a better way to achieve all of the above I will certainly consider them.
rzabransky said:It is my understanding that the CreationFilter is only called when the UIElement is first constructed.
Well, no, not really. UIElements are very transitory objects. They get created and destroyed all the time. So you are sort've correct that the CreationFilter fires when the elements are created. But not just the first time they are created - it happens every time they are created, and also when they are moved around or really any time anything in the control changes that requires updating the UIElements.
So the CreationFilter is ideal for modifying the ToolTipItem, as it will get triggered any time anything is changed.
The Cell.Appearance.Image property is excellent! That helps immensely. I had already begun to handle some text overflow and button elements but this is very handy.
It is my understanding that the CreationFilter is only called when the UIElement is first constructed. This behaviour is not useful to me as I require access to the UIElement while the user enters data. With the UIElement I can set the ToolTipItem to a class object which implements IToolTipItem and assume full control over the tooltip.The original need for this was a slight frustration on the limitations of how an UltraValidator would validate certain data and ultimately not display the tooltip when they are set properly within an embedded editor component (such as UltraComboEditor).
I recall earlier you mentioned using IDataErrorInfo (or the likes for error checking within a grid) but for a consistent L&F this was not possible. With a now greater understanding of how it all works this could be implemented simply I believe.Thanks for all your help, I will conclude to say the Image property on a cell was the answer to my original post.
I have created a support case for your behalf (CAS-51244-KS2XP8). Please send me more details about your scenario and I will research the options for you.
Regards,
Stefaniya
The problem with a DrawFilter is that you are simply drawing onto the grid. The grid has no knowledge that you did so, and so you might be drawing over other objects in the grid.
rzabransky said: - I am able to draw custom images where they are required. This includes headers, within dropdowns, etc.
Cell, Headers, and DropDowns in the grid all have the ability to show images, already via property settings on the Appearance.So using a DrawFilter doesn't really gain you anything, it's just a lot more work and a lot more code for the same effect. And, it has the disadvantage of the grid not moving the other elements around to fit the image.
rzabransky said:- I can use it as a cycle to immediately validate user entry and display feedback.
True, but you could achieve the same thing by handling events of the grid such as InitializeRow.
rzabransky said:- It allows me to attach customized tooltips to embedded UI elements. (especially editor components)
A CreationFilter would be better than DrawFilter for this.
I'm not trying to say that you should not be using a DrawFilter, I'm just trying to figure out exactly what you want to achieve so I can tell you the easiest way to do it. There are some very good reasons to use DrawFilters in some cases, but in most cases, using the properties on the grid is easier.
I think you would have a lot less trouble setting the appearance on a cell to provide an image, since this would handle the sizing and positioning of the image for you and all of your original questions in this thread would be solved. Or even setting the column's CellAppearace.Image to an empty image and then using the DrawFilter to draw into the ImageUIElement inside each cell would simplify things a lot, since the grid would reserve the image space and you could use the size of the ImageUIElement to determine the size to draw your image.