Hi All,
Keeping in view that culture-independent formatting is required I want to facilitate the application user to enter date in dd/MM/yy format in a column of DataGridView having DateTime type.
Following is my sample code for the said purpose.
Dim dgv As New DataGridView()
Me.Controls.Add(dgv)
Dim dt As New DataTable()
dt.Locale = System.Globalization.CultureInfo.InvariantCulture 'New System.Globalization.CultureInfo("en-gb")
Dim dc0 As New DataColumn("Name", System.Type.GetType("System.String"))
Dim dc1 As New DataColumn("DOB", System.Type.GetType("System.DateTime"))
dt.Columns.Add(dc0)
dt.Columns.Add(dc1)
Dim dr As DataRow = dt.NewRow()
dgv.DataSource = dt
dgv.Dock = DockStyle.Fill
dgv.Columns("Name").AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
dgv.Columns("DOB").DefaultCellStyle.Format = "dd/MM/yy"
dgv.Show()
Although I am able to format the column to the desired date format but it still forces user to enter the date in MM/dd/yy format as the regional setting in control panel is set to MM/dd/yy format.
Is there any way to achieve this without changing the local regional setting on the target system?
I have also tried
dt.Locale property but of no use.
Regards,
_______
Ali
Share your knowledge. It's a way to achieve immortality. - Dalai Lama MSN: kalilani@hotmail.com - Yahoo: kalilanipk