Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2921
  • Last Modified:

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

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
Eric Burton
Asked:
Eric Burton
  • 2
1 Solution
 
sognoctCommented:
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
 
Eric BurtonSr.ProgrammerAuthor Commented:
sognoct--

Did you mean embed a DateTimePicker in the DataGridViewColumn?
0
 
sognoctCommented:
Yes, it can be the simplest Solution
0
 
Monica PSoftware DeveloperCommented:
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

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now