Set single property label font style to bold and value background color?

5 posts, 1 answers
  1. Holger Boskugel
    Holger Boskugel avatar
    24 posts
    Member since:
    Apr 2012

    Posted 20 Apr 2012 Link to this post

    Hello,

    is there any way to set a single property Label font style to bold in the Grid? and is there also a way to set a different background color for the value input field?

    I want show the user this property value is required. For this purpose I created a PropertyStoreItemExtended class inheriting the PropertyStoreItem with an added property Required. Now I have to find a way to customize Label and/or Value field in case of the Required property value.

    Which PropertyGridEvent or (overridden) Methods can be used for that pupose?


    Greetings from Leipzig

    Holger Boskugel
    --
    http://vbwebprofi.de
  2. Answer
    Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 23 Apr 2012 Link to this post

    Hello Holger,

    Thank you for writing.

    You can use the ItemFormatting event to format the look of the properties. Since you have a property indicating whether the property is required, it would be a lot easier to implement the styling. You can read more regarding the ItemFormatting in our online documentation.

    I hope this will be useful for you. Should you have further questions, I would be glad to help.
     
    All the best,
    Ivan Petrov
    the Telerik team
    RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Holger Boskugel
    Holger Boskugel avatar
    24 posts
    Member since:
    Apr 2012

    Posted 23 Apr 2012 Link to this post

    Thanks, got it working in the right manner.

    Regards from Leipzig

    Holger Boskugel
  5. Sri
    Sri avatar
    5 posts
    Member since:
    Mar 2014

    Posted 18 Aug 2014 Link to this post

    I am trying to set the BackColor of only the value area to a different color, and haven't found a solution.  I am using the ItemFormatting event with the following code, but the value area color is not changing.  I am using the "ValueElement" below the main "VisualElement" to try and access just the value area of the item, but this does not seem to be working.   I can change the color of the entire row (label and value) by setting the BackColor on the main VisualElement, but I only want to change the value back color and not the label back color also.  Thank you.

    private void PropertyGrid_ItemFormatting(object sender, PropertyGridItemFormattingEventArgs e)
            {
                if (e.Item.Name == "TotalEndgunWettedArea")
                {
                    ((PropertyGridItemElement)e.VisualElement).ValueElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
                    ((PropertyGridItemElement)e.VisualElement).ValueElement.BackColor = Color.Red;
                }
            }


  6. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 21 Aug 2014 Link to this post

    Hello Sri,

    Thank you for writing.

    In addition to your code snippet related to the ItemFormatting event, you should set the PropertyGridItemElement.ValueElement.DrawFill property to true:
    private void radPropertyGrid1_ItemFormatting(object sender, PropertyGridItemFormattingEventArgs e)
    {
        PropertyGridItemElement itemElement = e.VisualElement as PropertyGridItemElement;
        if (itemElement != null && e.Item.Name == "AutoSizeMode")
        {
            itemElement.ValueElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
            itemElement.ValueElement.BackColor = Color.Red;
            itemElement.ValueElement.DrawFill = true;
        }
        else
        {
            e.VisualElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
            e.VisualElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
            e.VisualElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
        }
    }

    Since the control uses data virtualization (just like RadGridView and RadListControl) and you should always reset the values of the customized properties, in order to prevent applying the formatting to other items (because of the item reuse). Our RadPropertyGrid >> Customization help article is quite useful about items formatting.

    I hope this information helps. Should you have further questions, I would be glad to help.

    Regards,
    Desislava
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top
UI for WinForms is Visual Studio 2017 Ready