?
Solved

URGENT! VB.NET -- Need to format DataGridViewCell Value as Date ("MM/DD/YYYY")

Posted on 2013-01-19
4
Medium Priority
?
2,771 Views
Last Modified: 2013-01-29
Hi everyone,

When a user types a date value into a DataGridViewCell, I want to format it as "MM/DD/YYYY".

The underlying database table does not have any date columns hence the reason for forcing the input as a date.

Where should I start?

Thanks!
0
Comment
Question by:eq2006
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 9

Expert Comment

by:sognoct
ID: 38797267
you can set the cell format to datetimepicker

snippet here :
http://msdn.microsoft.com/en-us/library/7tas5c80.aspx?cs-save-lang=1&cs-lang=vb
0
 

Author Comment

by:eq2006
ID: 38797378
sognoct--

Did you mean embed a DateTimePicker in the DataGridViewColumn?
0
 
LVL 9

Expert Comment

by:sognoct
ID: 38797411
Yes, it can be the simplest Solution
0
 
LVL 10

Accepted Solution

by:
Monica P earned 2000 total points
ID: 38799990
Format as anyone type below

dataGridView1.Columns[0].DefaultCellStyle.Format = "MM'/'dd'/'yyyy";

OR

dataGridViewCellStyle.Format = "MM/dd/yyyy";
this.date.DefaultCellStyle = dataGridViewCellStyle;
// date being a System.Windows.Forms.DataGridViewTextBoxColumn
or
Refer this

http://stackoverflow.com/questions/7881085/convert-string-to-datetime-in-datagridview


Regular expression to check DateTime Format

http://www.aspdotnet-suresh.com/2012/07/regular-expression-to-validate-date-in.html
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question