Databound Combo - How to format date values

  • Thread starter Thread starter George Padvorac
  • Start date Start date
G

George Padvorac

Im running win2k and .net 1.1 I have a combo who's rowsource is a dataview.
The data being used are date values and this is what it looks like in the
dataset thats used for this dataview: "2003-06-14T00:00:00.0000000-05:00"

And the dates in the combo's list looks like this: 6/14/2003 12:00:00 AM

How can i format the dates in the dropdown list to look like this:
6/14/2003

Thanks.
 
Hello George,

You will need to obtain Binding object instance for the combo box. Each
control maintain DataBindings collection which usually contains a single
Binding instance.

Then you should subscribe to the Format and Parse events of this Binding
instance to provide your custom data parsing and formatting.

Or, you may bind your control manually like this:

Binding b = new Binding
("Text", ds, "customers.custToOrders.OrderAmount");
b.Parse += new ConvertEventHandler(CurrencyStringToDecimal);
b.Format += new ConvertEventHandler(DecimalToCurrencyString);
textBox3.DataBindings.Add(b);

(Code snippet taken from MSDN documentation on the DataBindings property).
 
Back
Top