This is a migrated thread and some comments may be shown as answers.

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

4 Answers 78 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 17 Sep 2013, 10:14 PM
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"));

4 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 20 Sep 2013, 12:13 PM
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 >>
0
Paul
Top achievements
Rank 1
answered on 20 Sep 2013, 08:17 PM
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?
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 25 Sep 2013, 01:24 PM
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 >>
0
Paul
Top achievements
Rank 1
answered on 25 Sep 2013, 06:30 PM
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;
Tags
PropertyGrid
Asked by
Paul
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Paul
Top achievements
Rank 1
Share this question
or