zoya
zoya

Reputation: 483

how to change the date format from mm/dd/yyyy to dd-mm-yyyy in combobox?

i have a combobox which is displaying date from database...in my database the date enteries are in the format of mm/dd/yyyy but i want to display them in the format of dd-mm-yyyy...in that combobox..when the application run.

Upvotes: 1

Views: 9952

Answers (2)

Jojo Sardez
Jojo Sardez

Reputation: 8568

You can either convert the format of your date before you load them to the combo box or run this code after the combobox have been filled:

for (int index = 0; index < this.comboBox1.Items.Count; index++)
        {
            this.comboBox1.Items[index] = DateTime.Parse(this.comboBox1.Items[index].ToString()).ToString("dd-mm-yyyy");
        }

Edited:

If your are using databinding and sure that the type of data being displayed is date. Try this:

 this.comboBox1.FormatString = "dd-MM-yyyy";

Upvotes: 2

Timores
Timores

Reputation: 14589

If you can accept to have a global change in the app, set the CultureInfo.CurrentCulture to a European locale.

Upvotes: 1

Related Questions