I am creating RichTextBox control with customize text color, font size, etc.When I tried to make this RichTextBox to be dockable using UltraDockManager, my font style (color, size, etc) get lost everytime I dock/float.
I have attached my example code for reference.
Please someone give me solution for this,
Thanks before.
This is really a million dollar question. I played around with this in my free time over the last day which probably resulted in a few hours wasted and still wasn't able to figure it out. I partly believe it's Microsoft related because not any events relating to the RichTextBox's content is touched. It just removes the formatting on itself.
Since the RichTextBox could be an annoyance to work with while the question is unanswered, you could use the work around of using the UltraFormattedTextEditor control instead.
Thanks for the reply.
I have played with RichTextBox on the last few days. And base on my research, RichTextBox has unique behavior. If we set text color using SelectionColor (like in my code), the color will got reset when RichTextBox.Font or RichTextBox.Text changed.
And then I tried to create user control inherit from RichTextBox. I override method OnFontChanged and OnTextChanged just for test purpose. When I tried docking/floating both of them triggered!
Perhaps somewhere in Infragistics library makes changes to the Font?
And really thanks for the suggestion, I will try UltraFormattedTextEditor for the time being as I need to solve this as soon as possible :)
Edo Gasali said: @tbetts1982 After some consideration, finally I am now using UltraFormattedTextEditor as you suggest as workaround mate. Thanks for your idea.
@tbetts1982 After some consideration, finally I am now using UltraFormattedTextEditor as you suggest as workaround mate.
Thanks for your idea.
You're welcome. The amount of code necessary to make the formatted editor a decent editor for users like that dialog would cause any programmer a headache. It's much easier to use the dialog than to reinvent the wheel. If they really intended users to click a button to open the dialog for editing an already editable textbox, why not cut out the middle man and work out a solution to combine the functionality of the dialog into their user control?
Hey, I really do appreciate your help mate!However I have did another workaround, resetting the text style in override method OnFontChanged().Basically it just clear and re-write the text.Sounds not a good way, but it works well without performance issue.
Thanks for your help!
This might not be the necessary answer you're looking for, but I did have fun hacking away at the WinFormattedTextEditor. When you're in the design view they give you this really nice editor for the value of that text editor, so I thought it would be nice to use that on a form as well. Here's my insane results, with Office 2007 color scheming!
You can really put that editor into any container. In this example I used the form's fill panel since I made use of the WinFormManager, but you can shove it into any panel you want.
Office2007ColorTable.ColorScheme = Office2007ColorScheme.Black; Infragistics.Win.SupportDialogs.FormattedTextEditor.FormattedTextUIEditorForm editor_form = new Infragistics.Win.SupportDialogs.FormattedTextEditor.FormattedTextUIEditorForm(); editor_form = new Infragistics.Win.SupportDialogs.FormattedTextEditor.FormattedTextUIEditorForm(ultraFormattedTextEditor1); editor_form.TopLevel = false; editor_form.FormBorderStyle = FormBorderStyle.None; editor_form.Dock = DockStyle.Fill; editor_form.Visible = true; Infragistics.Win.UltraWinToolbars.UltraToolbarsManager top_toolmanager = Infragistics.Win.UltraWinToolbars.UltraToolbarsManager.FromForm(editor_form); top_toolmanager.Style = Infragistics.Win.UltraWinToolbars.ToolbarStyle.Office2007; foreach (Control editor_control in editor_form.Controls) { switch (editor_control.Name) { case "pnlButtons": if (editor_control.Name == "pnlButtons") editor_control.Visible = false; break; case "ultraTabControl1": ((Infragistics.Win.UltraWinTabControl.UltraTabControl)editor_control).ViewStyle = Infragistics.Win.UltraWinTabControl.ViewStyle.Office2007; break; } } Form1_Fill_Panel.ClientArea.Controls.Add(editor_form);
This reply post was more of a for fun one, but if you have any questions about what I did above or how to change something, let me know.
I am looking around on UltraFormattedTextEditor finding the way to create multiple color in the text. Does it support multiple color in a textbox?On my previous sample project it just show a color, but on the actual I need it to support multiple color. That's the reason I use RichTextBox which support multiple text style in one place :)
Does anyone here have solution?I've found another person having the same problem last year and he doesn't get answered: http://community.infragistics.com/forums/p/47540/253744.aspx#253744Works around for multiple color in textbox is acceptable.Thanks.