Aditya B

Aditya B

  • NA
  • 6
  • 2.8k

Change DATE FORMAT for selected columns in datagridvew

Jan 25 2016 5:34 AM
Hi,
 
I have a data displaying in DataGridView. Among those few columns are having DATE columns where i need to change the format from MM/DD/YYYY to DD/MM/YYYY and  DD/MM/YYYY to MM/DD/YYYY .
 
I have created a button in FORM1. After clicking FORM1 (button), Another form opens where i have to select the column from the dropdown and click on OK. Form2 should close and Date format for selected should change in FORM1.
 
Please help me on this. Below is the code:
 
private void button3_Click(object sender, EventArgs e)
{
Date_Format df = new Date_Format();
df.cmbColumns.DataSource = cmbList;
df.ShowDialog();
string iString = df.cmbColumns.SelectedValue.ToString();
System.Globalization.CultureInfo.GetCultureInfo("en-GB");
DateTime oDate = DateTime.ParseExact(iString, "dd/MM/yyyy hh:mm:ss", System.Globalization.CultureInfo.CurrentCulture);// 
MessageBox.Show(oDate.ToString());
 

Answers (1)