Hi,
I'm trying to assign the same instance of an editor control to multiple bands of an UltraGrid, and it doesn't appear to be working correctly...
I've created a sub-class of the UltraFormattedTextEditor which simply adds an editor button to it. I've assigned the same instance to multiple bands, and while it works great within the same band, it does not appear to be working across bands. The first band will show the formatted text, but any other bands show the format source instead.
Should I be able to use the same instance across bands, or do I have to create an instance for each band?
Thanks
I think that instead of using the constructor of the control to add a button, you should override OnCreateControl and check to see if the button already exists before creating it; you may find this easier to do if you add a Key to the button. You are getting this designer error because at design-time the button is created in your constructor, then the .NET designer will serialize that button to the ButtonsRight collection. The next time that you open the form, your contructor will be called, which creates the button, then the InitiliazeComponent method will try to add that button again.
I can't really comment on the rest of the behavior, but let me know how if this button issue is solved via OnCreateControl.
-Matt
I was a little afraid of that.
I actually have several different grids that I'm using the same subclass in, and that ends up causing a designer bug because the places where I'm using the sublcass end up trying to add the button again, thus ending up with a duplicate key...
In my case it appears the editor isn't taking affect as I'm not getting the button either...
As far as the format source, I was meaning the HTML value of the cell, instead of the rendered view of it.
It must be something we're doing, I'll just have to hunt it down. Thanks.
If interested, the majority of the sublcass source is as follows...
public class HtmlUltraGridEditor : UltraFormattedTextEditor
{
/// <summary>
/// Creates a new instance of the AsYouTypeFormattedTextEditor.
/// </summary>
_editorButton = new EditorButton("...");
}
/// Returns the EditorButton used by this AsYouTypeFormattedTextEditor.
get
/// Enters the advanced editing for this cell.
/// <param name="cell"></param>
// opens a separate editor for more advanced editing
/// When the editor button is clicked, the advanced HTML editing dialog will be displayed.
/// <param name="e"></param>
You should be able to use the same instance of the control across multiple bands; in fact, with a non-derived UltraFormattedTextEditor I can add a button to the ButtonsRight collection and assign it to two different columns in two different bands and the button will appear corectly. I'm also not sure why you mean by showing the "format source".