Does anyone have an example or idea on embedding a user control within the cell (not drop down editor button) of a cell?
Currently I'm instantiating the usercontrol at runtime from class inheriting EmbeddableEditorBase, but I can't seem to get
the control to paint within the cell. I am also new to the Embeddable Editor archtecture so if anyone knows any good reference
sites that would be helpful. Thanks!
Creating your own editor is a very big task and probably requires several days, if not weeks, of coding - depending on the complexity of your editor and how familiar you are with the editors and how they work.If you intend to create your own editor, I recommend that you get a subscription to NetAdvantage that includes source code so you can use the existing editors as an example.
Generally, it's much easier to use or modify an existing editor to do what you need, rather than create a whole new editor on your own.
Oh... also, there's a sample of creating an editor. It's called the RichTextEmbeddableEditor sample. It's installed along with the rest of the NetAdvantage samples, which I think comes with the SDK now.
Thanks for your reply.
I looked into the DrawForeground method, which calls render method which inturn calls Render Helper method but nowhere they are getting the UltraGridCell object to display the value into the cell. As you mentioned, i tried to read the cell value, and it has the next subsequent cell value. (but its surprising that why it is not getting displayed though i hav the cell value of subsequent cells.)
But to recreate the issue in RichTextEditor sample code provided by Infragistics, i just comment out the below metioned line in RenderingHelper method in EmbeddableRichTextBox.cs file,
"SendMessage(handleRefHwnd, EM_DISPLAYBAND, IntPtr.Zero, ref fr.rc);"
From this, it is clear that they are getting the "RichTextBoX" handle (handleRefHwnd) and they display the value in the cell by sending EM_DISPLAYBAND message (This message is to display the value of the richtextbox). CORRECT ME IF I'M WRONG
So, to display the value in the Masked Edit box in the UltraGridCell what should be the message i need to pass (as like EM_DISPLAYBAND for RichTextBox) or if not possible through SendMessage how can i display the value in the Text in the UltraGridCell (i.e, how can i render MaskedEditBox) ?
It will be really helpful if u provide some solution for this.
Thanks..
Not sure on the masked edit box thing. But in the draw foreground override you can render your own graphics using the Graphics object and the drawstring method.
eg.
EmbeddableUIElement embeddableElement = embeddableUIElement;
SolidBrush sbrush = new SolidBrush(Color.Black);
format.Alignment = StringAlignment.Near;
sbrush,
embeddableElement.EditArea.X,
embeddableElement.EditArea.Y),
format);
Hi,
Thanks very much for the reply. Its working perfectly alright. But i need to change the font color at runtime. Since i'm using drawstring, i wont be able to do that at cell level (like cell.Appearance.Forecolor = Color.White) or row level.
Say for example, I have three columns "COL1", "COL2", "COL3" and three rows in the UltrawinGrid. I have my custom maked edit box control at "COL1" and the values forecolor will be Color.Black because i'm using the below mentioned line
Now, I have applied columnstyle property of "COL2" as ColumnStyle.Edit. So, whenever i click on "COL2" i need to change the fore color of "COL1" to white because i'm selecting the entire row (i.e, it should resembles like CellClickAction.Cellselect). But since i'm using DrawString, i wont be able to do that at cell level or row level. That is reason why i asked for rendering the masked edit box? or else it will be really helpful if anyother possible solution for this?
Thanks
You might want to use the ResolveAppearance method on the cell so that you can get the properties that you need. If you only want the ForeColor, you could do:
AppearancePropFlags requestedProps = AppearancePropFlags.ForeColor;AppearanceData appearance = new AppearanceData();cell.ResolveAppearance(ref appearance, requestedProps);SolidBrush sbrush = new SolidBrush(appearance.ForeColor != Color.Empty ? appearance.ForeColor : Color.Black);
-Matt
Thanks so much its working fine ..