all groups > dotnet ado.net > november 2004 >
You're in the

dotnet ado.net

group:

How can I format date in databound combobox in windows app?



Re: How can I format date in databound combobox in windows app? Sahil Malik
11/30/2004 5:56:08 PM
dotnet ado.net: George,

Here is how you do it -
PopulateDataSet();
Binding bnd = new Binding("Text", ds.Tables[0], "date");
bnd.FormatString = "dd-MM-yy";
bnd.FormattingEnabled = true;
comboBox1.DataBindings.Add(bnd);

Now, I don't have Visual Studio 2003 installed on my machine :-/ (or any of
my machines), and I suspect that FormatString was a new fangled thing
introduced in 2.0. So this just might be a 2.0 only thing. Atleast off the
top of my head, I don't remmeber seeing a FormatString property on Binding
in framework 1.1, but I could be wrong.

Anyway, thats how you do it. And this is yet another reason I am so anxious
to have 2.0 released !! HEHE :-)

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
http://blogs.apress.com/authors.php?author=Sahil Malik







[quoted text, click to view]

Re: How can I format date in databound combobox in windows app? Sahil Malik
11/30/2004 7:34:05 PM
BTW, even in 1.1, you could add a data column, set expression and bind with
that instead.

- Sahil Malik
You can reach me thru my blog -
http://www.dotnetjunkies.com/weblog/sahilmalik

[quoted text, click to view]

How can I format date in databound combobox in windows app? George P.
11/30/2004 10:22:04 PM
Hi,
I have a combobox bound to a smalldatetime column in a table.
The ComboBox displays all available dates.
However it displays them in long format and I want to display them in short
format.
Is this possible?

Re: How can I format date in databound combobox in windows app? George P.
12/1/2004 4:16:12 PM
Hi there,
VS.net 2003 doesn't have a FormatString property for binding,
but it has Format and Parse events that you can use. However it's not the
bound property that I want to format but the display member.
My combobox displays all possible dates from one column
and the selected value(which is taken from another column) is bound to
another table.
I want to perform formatting on the displaymember
not on the selected value which is databound.
cheers,
george

[quoted text, click to view]

Re: How can I format date in databound combobox in windows app? Sahil Malik
12/1/2004 9:09:05 PM
George,

As in the pasted code - the use "Text" as the first parameter.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik



[quoted text, click to view]

AddThis Social Bookmark Button