Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
975
Icon in Rowselector
posted

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;

So now I've got the warning image in the rowselector.  Now I want to show a tooltiop when I hover over the warning image, and I thought I'd use the MouseEnterElement event to look for the rowSelector with the image.

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:

if (e.Element is RowSelectorUIElement)

{

 

RowSelectorUIElement rs = (RowSelectorUIElement)e.Element;

UltraGridRow row = rs.Row;

//Image imgList = row.RowSelectorAppearance.GetImage(imgList);// rs.Row.RowSelectorAppearance.GetImage(imgList);

Image img = (Image)row.RowSelectorAppearance.Image;if (img != null)

{

Console.WriteLine("Image in rowselector");

}

This works for me but maybe there's a much better way to accomplish this?

Thanks,

Bill

Parents
  • 469350
    Offline posted

    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.

Reply Children