Conditional Formatting Rules Manager

2 posts, 0 answers
  1. Sagar
    Sagar avatar
    1 posts
    Member since:
    Jun 2020

    Posted 05 Jun 2020 Link to this post

    Hi,

    We have used a Telerik RadGridView in our Windows Application.

    On specific form user has a option to right mouse click and open conditional formatting

    then user gets a popup window of Conditional Formatting Rules Manager. 

    In that Rules Manager window - we can see some properties under Format section such as CellBackColor and RowBackColor.

    for these very particular options CellBackColor and RowBackColor we have set some standard color from code and want to keep it as a standard

    thus want to prevent user to go and edit these properties and change the color to something else. 

    So is it possible to completely disable to edit/hide these options (CellBackColor and RowBackColor) from code, so end user could not change it ?

    Please find attached image of Rules Manager.

     

     

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    4086 posts

    Posted 09 Jun 2020 Link to this post

    Hello, Sagar, 

    In order to disable the CellBackColor and RowBackColor options in the conditional formatting dialog, it is necessary to handle the ConditionalFormattingFormShown event and access the property grid that is used in the Format section. Then, disable these particular items in the RadPropertygrid.ItemFormatting event. 

            public RadForm1()
            {
                InitializeComponent();
                this.radGridView1.ConditionalFormattingFormShown += radGridView1_ConditionalFormattingFormShown;
            }
    
            private void radGridView1_ConditionalFormattingFormShown(object sender, EventArgs e)
            {
                ConditionalFormattingForm form = sender as ConditionalFormattingForm;
                RadPropertyGrid propertyGrid = form.Controls["radPropertyGridProperties"] as RadPropertyGrid;
                if (propertyGrid != null)
                {
                    propertyGrid.ItemFormatting -= propertyGrid_ItemFormatting;
                    propertyGrid.ItemFormatting += propertyGrid_ItemFormatting;
    
                    propertyGrid.Editing -= propertyGrid_Editing;
                    propertyGrid.Editing += propertyGrid_Editing;
                }
            }
    
            private void propertyGrid_Editing(object sender, PropertyGridItemEditingEventArgs e)
            {
                if (e.Item.Label == "CellBackColor" || e.Item.Label == "RowBackColor")
                {
                    e.Cancel = true;
                }
            }
    
            private void propertyGrid_ItemFormatting(object sender, PropertyGridItemFormattingEventArgs e)
            {
                if (e.Item.Label == "CellBackColor" || e.Item.Label == "RowBackColor")
                {
                    e.VisualElement.Enabled = false;
                }
                else
                {
                    e.VisualElement.Enabled = true;
                }
            }

    I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

    Regards,
    Dess | Tech Support Engineer, Sr.
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.
Back to Top