Persisting the “Show description” and “Show toolbar” settings in the context menu

5 posts, 1 answers
  1. Paul
    Paul avatar
    23 posts
    Member since:
    Feb 2013

    Posted 17 Sep 2013 Link to this post

    Do you guys have an example on how I would remember the whether the user selected or deselected the “Show description” and “Show toolbar” settings in the property grid context menu? I tried casting the items as a PropetyGridMenuItem in the RadContextMenu_DropDownClosed event, but IsChecked is always set to true. Here is the code:

    PropertyGridMenuItem descriptionItem = radPropertyGrid.RadContextMenu.Items[6] as PropertyGridMenuItem;
    if (descriptionItem != null && !descriptionItem.IsChecked)
            File.Create(System.IO.Path.Combine(path, "PropertyGridDescriptionUnchecked.txt"));
  2. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 20 Sep 2013 Link to this post

    Hello Paul,

    Thank you for contacting Telerik Support.

    It is necessary to use the ToggleState property of the PropertyGridMenuItem in order to check if it is in checked/unchecked state:
    PropertyGridMenuItem descriptionItem = radPropertyGrid1.RadContextMenu.Items[6] as PropertyGridMenuItem;
     
    if (descriptionItem != null && descriptionItem.ToggleState!= ToggleState.On)
     
        File.Create(System.IO.Path.Combine(@"C:\", "PropertyGridDescriptionUnchecked.txt"));

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

    Regards,
    Desislava
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Paul
    Paul avatar
    23 posts
    Member since:
    Feb 2013

    Posted 20 Sep 2013 Link to this post

    When the RadContextMenu_DropDownClosed event is fired and the "Show description" item has just been unchecked, descriptionItem.ToggleState is still set to On. The next time the RadContextMenu is opened, the ToggleState is set to Off. It turns out this behavior is the same for the IsChecked property.

    Is there some other event to listen for when the Description and Toolbar items are added/removed from the property grid?
  5. Answer
    Dess
    Admin
    Dess avatar
    1601 posts

    Posted 25 Sep 2013 Link to this post

    Hello Paul,

    Thank you for writing back.

    It is appropriate to use the ToggleStateChanged event of a certain PropertyGridMenuItem if you want exactly to trace checking/unchecking "Description" item for example:
    public Form1()
    {
        InitializeComponent();
     
        PropertyGridMenuItem descriptionItem = radPropertyGrid1.RadContextMenu.Items[6] as PropertyGridMenuItem;
        if (descriptionItem != null)
        {
            descriptionItem.CheckOnClick = true;
            descriptionItem.ToggleStateChanged += descriptionItem_ToggleStateChanged;
        }
    }


    private void descriptionItem_ToggleStateChanged(object sender, StateChangedEventArgs args)
    {
        if (args.ToggleState == ToggleState.On)
        {
            //do something
        }
    }

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

    Regards,
    Desislava
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  6. Paul
    Paul avatar
    23 posts
    Member since:
    Feb 2013

    Posted 25 Sep 2013 Link to this post

    Thanks, just what I was looking for.

    For anyone else trying to programmatically hide the property grid description bar, this is the code you need:
    radPropertyGrid.PropertyGridElement.SplitElement.HelpVisible = false;
Back to Top
UI for WinForms is Visual Studio 2017 Ready