all groups > dotnet windows forms designtime > june 2004 >
You're in the

dotnet windows forms designtime

group:

Making a property editable ONLY BY CUSTOM EDITOR


Making a property editable ONLY BY CUSTOM EDITOR Bill Foust
6/15/2004 12:04:25 PM
dotnet windows forms designtime:
I have a property which is a basic type and I have a custom editor on the
property. The value of the property shows up as editable with the "..."
button to launch the custom editor. However I want to PREVENT the user from
editing the value by simply typing it in. I want to force the user to launch
the custom editor. Is there a secret attribute to do this?

Thanks
Bill

RE: Making a property editable ONLY BY CUSTOM EDITOR v-yiy NO[at]SPAM online.microsoft.com (
6/16/2004 8:36:40 AM
Hi Bill,

You may try specifying a Type Converter class for your property,
here is a quick sample shows how to do this, for simplicity I defined a
Property in Font type, you may add this code snippet to a user control then
add the user control to the Form, now the MyFont property displays a string
returned from Font.ToString() and a button with "...", you may edit the
value using Font Dialog but the text field of the property is not editable.

<code>
[
TypeConverter(typeof(TypeConverter))
]
public Font MyFont
{
get
{
return this.Font;
}
set
{
this.Font = value;
}
}
<code>
Does it resolve your probem?
Feel free to reply this thread if you have anything unclear about it.

Have a nice day!


Best regards,

Ying-Shen Yu [MSFT]
Microsoft Community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
AddThis Social Bookmark Button