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
210
How to insert formatted text through code?
posted

Hi,

I have a Windows form having a UltraFormattedTextEditor, and a button.

When I click that button it will insert some text("User") in the UltraformattedTextEditor . When I insert that text i want to change the background of the text to "Yellow" and make it Bold, and after that if i type something it will appear as normal text, with default background.

i want to achive it through C# code. If it is possible, please provide me some sample.

Thanks,

 

  • 5520
    Suggested Answer
    posted

       private void ultraButton1_Click(object sender, EventArgs e)
            {
            
                ultraFormattedTextEditor1.Appearance.BackColor = Color.Yellow;
                ultraFormattedTextEditor1.Appearance.FontData.Bold = Infragistics.Win.DefaultableBoolean.True;
                ultraFormattedTextEditor1.Text = "User";
            }

     private void ultraFormattedTextEditor1_ValueChanged(object sender, EventArgs e)
            {
                if (ultraFormattedTextEditor1.Text != "User")
                {
                    ultraFormattedTextEditor1.Appearance.BackColor = Color.Empty;
                    ultraFormattedTextEditor1.Appearance.FontData.Bold = Infragistics.Win.DefaultableBoolean.Default;
                }
            }

    hope this helps

  • 12773
    posted

    Hi,

    You can use the standard styles for applying a background and change the font appearance here is some help about this:
    http://help.infragistics.com/Help/NetAdvantage/NET/2008.2/CLR2.0/html/infragistics2.Win.Misc.v8.2~Infragistics.Win.FormattedLinkLabel.UltraFormattedTextEditor~ContextMenuItems.html

    About the clearing question you, it seems that you want to clear all styles that you set, but you didn’t mention is there any difference where (in the formatted text or not) you type something and do you want to clear formatting only for the typed text or for the whole content.

    Here is some help how to clear specific style:
    http://help.infragistics.com/Help/NetAdvantage/NET/2008.2/CLR2.0/html/WinFormattedTextEditor_Clearing_Specific_Styles_from_Formatted_Text.html
    I make sample which clear the styles that you mentioned by typing in the formatted editor text area.

    You also can look at the sample project in your Sample Browser under section “Commands and editors/ToolBars/Ribbon with Formatted text editor”.

    I hope this information is helpful.

    Sincerely,
    Dimi
    Developer Support Engineer
    Infragistics, Inc.

    FormattedTextEditor.zip