开发者

Preventing Visual Studio Designer from Setting Text Property on Creation

I've got a problem with Visual Studio Designer's convention of setting the text in a TextBox to the 开发者_如何学Cname of the control. I've got a control that accepts a Social Security Number, and the Text property is overridden so as to throw an exception if the text is not in the correct format (e.g. 123-45-6789 or 123456789). When I try to use the control in the designer, this exception is thrown because Visual Studio is trying to name the control cssnTextBox1. Is there an attribute I can place on the Text property to prevent the designer from setting it?


Take a look at this discussion: how to detect design time in C# control.

http://vidmar.net/weblog/archive/2005/04/11/1246.aspx

You need to disable the Text property validation, if control's container is in design mode.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜