Question

I have a windows form application. I have a query which return me datetime in the format dd-MM-yyyy. But when this datetime is displayed in a datagrid it is displayed as dd/MM/yyyy. I wish to display dd-MM-yyyy in my datagrid. How can this be achieved.

Was it helpful?

Solution

You set this in the column's DefaultCellStyle.Format:

this.dataGridView1.Columns["Date"].DefaultCellStyle.Format = "dd-MM-yyyy";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top