Custom formatter
Thanks,
Valentin iliescu
It seems like adding Format and Parse event handlers to your text control's Binding would accomplish what you want.
If you are working in Visual Studio 2005, take a look at the MaskedTextBox. You can use this control to format data, and if you implement a MaskDescriptor for your type, the MaskedTextBox's Input Mask dialog will support your type at design time.
As Durstin suggested, you can use Format/Parse events as the sample below shows. You can also package this conversion up into a TypeConverter and put a TypeConverter attribute on your property. This provides a better separation between your UI and display logic however there is a bug in B2 (being fixed) where TypeConverters are not honored for properties so I have not included that sample.
Joe
private void Form1_Load(object sender, EventArgs e) { List<string> squares = new List<string>(); for (char jdx = 'a'; jdx <= 'h'; jdx++) ChessPiece cp = new ChessPiece(); b.Format += delegate(object fSender, ConvertEventArgs fArgs) b.Parse += delegate(object pSender, ConvertEventArgs pArgs) this.textBox1.DataBindings.Add(b); |
Where can I find some doc about MaskDescriptor.
I looked at the IPv5 sample and I don't really see how it works.
Thanks in advance,
Philippe