バインディング時の書式設定
テキストボックスにバインディングした場合に、3桁区切りや、小数点以下の表示制御などをしたい場合には、Binding.Formatイベントで実現できる。
これはGUIでは設定不可かも。
Binding.Format イベント
http://msdn2.microsoft.com/ja-jp/library/system.windows.forms.binding.format(VS.80).aspx
C#のコード例
private void DecimalToCurrencyString(object sender, ConvertEventArgs cevent) { // The method converts only to string type. Test this using the DesiredType. if(cevent.DesiredType != typeof(string)) return; // Use the ToString method to format the value as currency ("c"). cevent.Value = *1 return; // Converts the string back to decimal using the static Parse method. cevent.Value = Decimal.Parse(cevent.Value.ToString(), NumberStyles.Currency, null); } private void BindControl() { // Creates the binding first. The OrderAmount is a Decimal type. Binding b = new Binding ("Text", ds, "customers.custToOrders.OrderAmount"); // Add the delegates to the event. b.Format += new ConvertEventHandler(DecimalToCurrencyString); b.Parse += new ConvertEventHandler(CurrencyStringToDecimal); text1.DataBindings.Add(b); }