Set Mask property on MaskedTextBoxPropertyEditor at runtime

Grids for WPF Forum

Posted 13 years ago by Sarah
Version: 11.1.0542
Avatar
I'm having some difficulty trying to use the MaskedTextBoxPropertyEditor in the property grid. I have decorated the properties with the EditorAttribute and editor type, and have also added the editor to the property grid. For example:

[Editor(typeof(MaskedTextBoxPropertyEditor), typeof(PropertyEditor))]
public string MaskedString { get; set; }
        
<propgrid:PropertyEditorsModifierActionAdd>
    <propgrideditors:MaskedTextBoxPropertyEditor />
</propgrid:PropertyEditorsModifierActionAdd>
Where is the best place to set the Mask property of the editor (it is required to change at runtime)? I have tried setting it when adding the editor to the property grid, but this isn't working for me. For example:
<propgrid:PropertyEditorsModifierActionAdd>
    <propgrideditors:MaskedTextBoxPropertyEditor Mask="\d+"/>
</propgrid:PropertyEditorsModifierActionAdd>
I can't seem to find an example in the sample project. Is there another step that I am missing?

Many thanks,
Sarah

Comments (3)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Sarah,

If you need to bind the MaskedTextBox.Mask property to a property the selected object (i.e. the object assigned to the PropertyGrid.SelectedObject property), then you'd need to use a custom property editor. You wouldn't be able to use our MaskedTextBoxPropertyEditor to change it at runtime.

If you can please put together a small sample project that shows exactly what you are trying to do then we can take a closer look. Be sure to remove any executables or change the extension of the zip file to ensure it gets past our email filters.


Actipro Software Support

Posted 10 years ago by Raphael
Avatar

Hello,


I have the exact same problem: How can I get access to the property Mask of a MaskedTextBoxPropertyEditor (or custom property editor) at runtime? What I want to create is a masked text box property with a dynamically variable Mask.


Thank you.

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Raphael,

It depends on where your MaskedTextBoxPropertyEditor instance is stored.  If you defined it via Resouces in a propgrid:PropertyEditorsModifier, you would need to get the resource instance and then find the MaskedTextBoxPropertyEditor in there and update its Mask property.  But note that in order to get the PropertyGrid to update the mask of its control instances, you'd probably need to call the PropertyGrid.Refresh method.

If you have any trouble with that, please make a new simple sample project that shows the issue and email that to our support address.  Reference this thread and rename the .zip file extension so it doesn't get spam blocked.


Actipro Software Support

The latest build of this product (v24.1.2) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.