"Cor Ligthert" <no************@planet.nl> wrote in
news:eF**************@tk2msftngp13.phx.gbl:
For that are the binding format events.
Very simple to use when you know them
Ive said it before and I'll say it again - they WAY overdid the data
bindings to the point that they are a REAL PITA to use in many cases. If
they want to architect the snot out of things thats fine, but at LEAST
engineer in some shortcuts for the routine stuff (Re my codeproject article
on grids) or this case.. In Delphi or even VB it would be simple - put a
format string on the control, or at worst make a calculated field...
WinForms? No way.. because noone at MS actually uses the WinForms stuff, so
its "Academic".. ok rant off... At least with ADO.NET, ASP.NET and most of
the rest of .NET, people at MS actually use it for something other than
demos.. ;(
Ok this is still way too much code to do something this soddingly simple.
If you say its so simple please show me because I dont want to spend hours
on trial and error.. Here is what Ive tried:
private void DecimalToCurrencyString(object sender, ConvertEventArgs
cevent) {
if (cevent.DesiredType == typeof(string)) {
cevent.Value = ((decimal)cevent.Value).ToString("n2");
}
}
private void lablUnprocessedOrderCount_BindingContextChanged(ob ject
sender, System.EventArgs e) {
((Control)sender).DataBindings[0].Format += new ConvertEventHandler
(DecimalToCurrencyString);
}
It hits the code - but the label now display blank instead of the value.
cevent.value is getting set to a string, and its not blank.
--
Chad Z. Hower (a.k.a. Kudzu) -
http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
Develop ASP.NET applications easier and in less time:
http://www.atozed.com/IntraWeb/