Hello,
I have a column bound to Boolean data, and instead of showing a checkbox control in each cell, I want to show an image for true and no image for false. I am doing this in the context of a re-usable component (I'll call it the "grid host") that can add columns to the grid at run-time.
I am attempting to achieve this by using an UltraCheckEditor and my own GlyphInfoBase class whenever the grid host adds a bound Boolean column to the grid. In the handler for the InitializeLayout event of the grid, I do the following for this special column.
The result is that I'm still getting checkboxes in this column instead of my image. Also, when I set a breakpoint in the Click event handler, I found that the EditorComponent property on the column is now null.
However, if I move the section of code that creates the UltraCheckEditor so that it executes in response to the InitializeRow event instead of InitializeLayout, my image shows up correctly. This doesn't seem like the correct solution though.
So, am I attaching to the wrong event for creating my UltraCheckEditors, or am I doing something else wrong?
I've left out a lot of details in an attempt to be brief. I can provide more detail if necessary.
Hi Andrew,
I assume you are setting the EditorComponent property on the column and not the cell. Is that correct?
When you click, are you also checking the EditorComponent on the column and not the cell?
I don't see anything in your description here that could explain why the EditorComponent is being set to null. The grid certainly does not do this for any reason that would have anything to do with GlyphInfo. My guess is that something in your code is doing this inadvertently.
The most obvious thing that springs to mind is that you are loading a Layout into the grid. Check your code for "DisplayLayout.Load" or similar code.
Another possibility is that your InitializeLayout event is taking different paths. Maybe the part of the code that sets the EditorComponent is getting skipped sometimes and the InitializeLayout event is firing more than once? That should only happen if you are setting the DataSource/DataMember on the grid more than once, of course.
Mike,
Good call, you're exactly right; I'm using DisplayLayout.LoadFromXml, and it looks like my EditorComponent is being set to null during that call. I'm setting up the layout programmatically, and then IF the user has used this particular instance of the grid before and changed the layout, it restores that layout. To answer your questions:
So it looks like the problem is at least one of the following:
Regarding number 1 above, my GlyphInfoBase class was not implementing ISerializable, nor did it have the [Serializable] attribute on it, nor did it provide the special protected constructor for deserialization. So I added all that, but it looks like the issue still remains, i.e. EditorComponent is null after I reload the user's layout. I looked inside the XML that is being saved, and I don't see any reference to my GlyphInfoBase class, and the only EditorComponent-related info I see is: <EditorComponentName href="#ref-135"/>.
I've worked around the issue via option 3 above, but I am curious to read your response to this post. Thanks!