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
Ultragrid title text font question

how can we write formatted text in the caption of the ultragrid.

example: TOTAL AMOUNT: 123456 (the number is in bold while the letters are regular) ??

  • 12480
    Verified Answer
    Offline posted

    Hi Ahmad,

    I've put together a small sample that demonstrates how you might do this using a Creation Filter. The relevant code looks like this:

    public bool BeforeCreateChildElements(UIElement parent)
        if (parent is CaptionAreaUIElement)
            // Reuse the existing FormattedTextUIElement if there's already one there
            FormattedTextUIElement childElement = parent.ChildElements.OfType<FormattedTextUIElement>().FirstOrDefault();
            if (childElement == null)
                childElement = new FormattedTextUIElement(parent);
            // In order to customize the formatted text that appears in the caption, modify this statement
            string formattedText = "<p align = \"center\">" + (parent.Control as UltraGrid).Text + "</p>";
            childElement.Value = ParsedFormattedTextValue.Parse(formattedText, ParsedFormattedTextValue.ValueType.AutoDetect, out Exception ex);
            childElement.Rect = parent.RectInsideBorders;
            return true;
        return false;

    In this sample, I'm using the formatted text to center the caption, which reproduces the effect of the original implementation. You should modify the format as per your application's needs. You can find more information about Formatting Text and what types of formatting is supported in our help.

    I've attached the full sample in case you would like to see it running.

    Please let me know if you have any further questions.

Reply Children