How do I raise a property error without killing the IDE?

J

Jeff Johnson

[This isn't really a C# question, but the IDE group is all but dead, so I'm
crossposting....]

I have a user control that should only accept fixed-width fonts for its Font
property. If the user tries to assign a proportional font, I want to return
an error. This works fine for code, but if the user sets the font via the
Properties window in the IDE, my error ("throw new Exception(<blah>)") locks
the IDE up solid. I want it to work more like, for example, when you try to
set the (name) property of a control to something invalid. A little message
box pops up telling you that the "Property value is invalid" or words to
that effect. Any idea how to do that?
 
J

Jeff Johnson

[...]
I want it to work more like, for example, when you try to
set the (name) property of a control to something invalid. A little
message
box pops up telling you that the "Property value is invalid" or words to
that effect. Any idea how to do that?

Maybe check the DesignMode property and display the MessageBox instead of
throwing an exception if the property is set to "true"?

Ahhh, from Component. I looked for such a thing, but I must have only looked
in the Public properties section and not Protected. I'll give it a shot!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top