I got one for ya and feel free to jump in at anypoint to tell me where I've gone wrong.
Concerning data error icons, I want to distinguish between errors and warnings. If I had a warning situation, based on business rules, I want to show a warning icon, an image of my choosing, not the red exclamation point, in both the cell and row selector. I could'nt find a way to customize the error icon at the ado.net layer, so I moved onto the grid.
So when I have a warning condition for a cell, I do this at the row level: (cell too, but I'll leave that alone for now)
grid.ActiveRow.RowSelectorAppearance.Image = _warningImage;
But using the UIElementViewer, surprisingly, I see that the image doesn't register in the viewer. Nothing at all. Ths is what I see, just a rowSelectorUIElement:
RowUIElement, Location = {X=1,Y=150,Width=410,Height=18} RowSelectorUIElement, Location = {X=1,Y=151,Width=31,Height=17}
A regular dataErrorIcon, the out-of-the-box red ! that you get with a datarow.setColumnError(), shows up as an ImageUIElement under a DataErrorIconUIElement. Like this:
RowCellAreaUIElement, Location = {X=31,Y=150,Width=380,Height=18} CellUIElement, Location = {X=116,Y=151,Width=99,Height=16} DataErrorIconUIElement, Location = {X=117,Y=151,Width=16,Height=16} ImageUIElement, Location = {X=119,Y=153,Width=12,Height=12}
So, in a MouseEnterElement event, I get the row object and from that the image from the RowSelectorAppearance:
{
UltraGridRow row = rs.Row;
//Image imgList = row.RowSelectorAppearance.GetImage(imgList);// rs.Row.RowSelectorAppearance.GetImage(imgList);
Console.WriteLine("Image in rowselector");
}
Thanks,
Bill
Hi Bill,
It looks like the RowSelectorUIElement is drawing the image directly rather than containing an ImageUIElement. This is unusual, but not unheard of. I'm not sure why it was done that way.
The code you have here should work fine for the situation you are in. The only down side of examining the Image property like you are doing here is that this will not work if you assign the image to a more general appearance. For example, if you apply an image to ALL RowSelectors via the RowSelectorAppearance on the Override, the RowSelectorAppearance of the individual row will not reutrn that image. But I imagine you are not going to apply a default image to all RowSelectors and even if you did, this is exactly what you would want to happen.
Mike,
I've been trying to figure out if there's any way to add padding to the left and right of the image displayed in a row selector. I assume that given your response above, it's not possible to change the properties of the image being displayed i.e. the image's bounding box?
There no property for padding the image. But there are a couple of ways you could do it.
The easiest way I can thik of would be to add padding to the image. This would be pretty easy to do in code. Just create a new image that is slightly wider than your "real" image, fill it with the Transparent color, then draw your image into the middle of it.