PropertyGrid Is there a way to disable editing "in the propertygrid" but allow a Custom Editor to still work?

1 Answer 19 Views
PropertyGrid
Curtis
Top achievements
Rank 1
Iron
Iron
Veteran
Curtis asked on 01 Apr 2025, 09:43 PM

I have a Winform that includes a Grid that my Users can edit by adding/removing columns.

I have an Object ("gridProps" class) that holds all of the "grid" properties,

gridProps.Columns property replaces the default (text) editor with my own popup radForm that works very much like your own "Columns" property for radGrid.  When the user clicks into that Property on the PropertyGrid, you get a string representation and a "..." button.  Clicking on that button bring up my "Columns Editor" radForm and takes over until "OK" or "Cancel"

Everything works...except: The user can click into "Columns" on the PropertyGrid and it automatically opens the "Textbox" editor inside the PropertyGrid and the user can type away.  Nothing happens with this input - my TypeConverter sees to that but they are still allowed to type whatever they want until they click away or hit enter/tab etc.

Is there a way to PREVENT the user from typing anything but STILL ALLOW them to click the "..." button?

I'm trying to mimic exactly how Telerik RadGrid's Columns property works.

Any advice would be helpful and appreciated!

-C

 

 

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 04 Apr 2025, 11:07 AM

Hello Curtis,

If I have correctly understood your scenario, you want to prevent the user from typing into the editor textbox and leaving the button (with the 3 dots) active. What you can try in this case is to subscribe to the EditorInitialized event handler of the control. Then you can access the TextBox from the editor property.

private void RadPropertyGrid1_EditorInitialized(object sender, PropertyGridItemEditorInitializedEventArgs e)
{
    if (e.Editor is PropertyGridUITypeEditor uITypeEditor)
    {
        (uITypeEditor.EditorElement as PropertyGridUITypeEditorElement).TextBoxItem.ReadOnly = true;
    }
}

If the above code snippet is not working, you can debug the code and check the type of the e.Editor in your case and pass the correct type.

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Enjoyed our products? Share your experience on G2 and receive a $25 Amazon gift card for a limited time!

Curtis
Top achievements
Rank 1
Iron
Iron
Veteran
commented on 04 Apr 2025, 07:18 PM

This is perfect, Dinko!  All my years with Telerik and this is my first experience with the PropertyGrid.  Perfect, thank you!
Tags
PropertyGrid
Asked by
Curtis
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or