0

I am using a Custom TextBox control in WinForms application. I want a property such that it has multiple values just like a combo box. Now when I choose any value in designer mode then how will that value get reflected in the CustomControl. I am not getting the logic. Kindly give any suggestion or hint.

Please comment if you need more info.

Murtaza Munshi
  • 1,065
  • 4
  • 13
  • 40
  • What should be the behavior of the control? What's your design-time and run-time requirement? – Reza Aghaei Jul 27 '16 at 14:43
  • I need a property to validate, it will have three validationrules - a,b & c (say). Now in design mode when i select b validationrule then validationprovider attached to the customcontrol should use that b validationrule in it. – Murtaza Munshi Jul 28 '16 at 09:01
  • If just using showing a dropdown in property grid is enough, you can define an enum containing a, b and c. Then define a public property of type of that enum. This way the property grid will show a dropdown containing enum values for the property. – Reza Aghaei Jul 28 '16 at 11:03
  • If showing just a dropdown for the property is not enough and for example some different properties should be for the selected rule, take a look at this post: [WinForms designer properties of different derived types](http://stackoverflow.com/questions/37931785/winforms-designer-properties-of-different-derived-types). It's suitable for cases when each validation rule has its own properties. – Reza Aghaei Jul 28 '16 at 11:05

0 Answers0