Click here to Skip to main content
15,924,901 members
Home / Discussions / C#
   

C#

 
GeneralRe: Using XML as a data source Pin
Rafone7-Aug-09 17:17
Rafone7-Aug-09 17:17 
AnswerRe: Using XML as a data source Pin
Rafone7-Aug-09 18:29
Rafone7-Aug-09 18:29 
QuestionFormat date mm/dd/yyyy Pin
Wheels0127-Aug-09 9:08
Wheels0127-Aug-09 9:08 
AnswerYou can cheat it a little Pin
Ennis Ray Lynch, Jr.7-Aug-09 9:16
Ennis Ray Lynch, Jr.7-Aug-09 9:16 
GeneralRe: You can cheat it a little Pin
Wheels0127-Aug-09 9:19
Wheels0127-Aug-09 9:19 
AnswerRe: Format date mm/dd/yyyy Pin
musefan7-Aug-09 9:16
musefan7-Aug-09 9:16 
GeneralRe: Format date mm/dd/yyyy Pin
Wheels0127-Aug-09 9:20
Wheels0127-Aug-09 9:20 
GeneralRe: Format date mm/dd/yyyy Pin
musefan7-Aug-09 9:47
musefan7-Aug-09 9:47 
Maybe try something like this...

DateTime dt = DateTime.Now;
if(DateTime.TryParseExact("DATEVALUE", "MM/dd/yy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dt))//has short year
{
     //NOTE 1
     DataGridViewCell.Value = dt.ToString("MM/dd/yyyy");
}
else if(!DateTime.TryParseExact("DATEVALUE", "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dt))
{
     //not valid format so do some error handling
}


NOTE 1: you could add some logic here to test if the year is 20 but I would suggest you leave trying not to allow it to be converted to 2020 as that is what should be expected, plus if you validate each cell when it has lost focus then the user will see the change and can edit if it is wrong

Life goes very fast. Tomorrow, today is already yesterday.

GeneralRe: Format date mm/dd/yyyy Pin
PIEBALDconsult7-Aug-09 10:45
mvePIEBALDconsult7-Aug-09 10:45 
GeneralRe: Format date mm/dd/yyyy Pin
Mycroft Holmes7-Aug-09 22:32
professionalMycroft Holmes7-Aug-09 22:32 
GeneralRe: Format date mm/dd/yyyy Pin
PIEBALDconsult8-Aug-09 6:50
mvePIEBALDconsult8-Aug-09 6:50 
AnswerRe: Format date mm/dd/yyyy Pin
Mycroft Holmes7-Aug-09 22:34
professionalMycroft Holmes7-Aug-09 22:34 
Questionconnections strings in Linq Pin
Chazzysb7-Aug-09 8:57
Chazzysb7-Aug-09 8:57 
AnswerRe: connections strings in Linq Pin
Super Lloyd7-Aug-09 14:58
Super Lloyd7-Aug-09 14:58 
Questionwinform add splitcontainer docking problem-panel is covered by toolstrip Pin
akira327-Aug-09 8:54
akira327-Aug-09 8:54 
AnswerRe: winform add splitcontainer docking problem-panel is covered by toolstrip Pin
Alan N7-Aug-09 10:09
Alan N7-Aug-09 10:09 
AnswerRe: winform add splitcontainer docking problem-panel is covered by toolstrip Pin
Henry Minute7-Aug-09 15:38
Henry Minute7-Aug-09 15:38 
Questionhow to Retrieve Metadata in office Document using Index Services. Pin
alisolution7-Aug-09 8:28
alisolution7-Aug-09 8:28 
Questionstripping out http response header using Regex.Replace Pin
Jayapal Chandran7-Aug-09 8:15
Jayapal Chandran7-Aug-09 8:15 
AnswerRe: stripping out http response header using Regex.Replace Pin
Moreno Airoldi8-Aug-09 0:48
Moreno Airoldi8-Aug-09 0:48 
QuestionRe: stripping out http response header using Regex.Replace Pin
Jayapal Chandran9-Aug-09 8:43
Jayapal Chandran9-Aug-09 8:43 
AnswerRe: stripping out http response header using Regex.Replace Pin
Moreno Airoldi9-Aug-09 23:34
Moreno Airoldi9-Aug-09 23:34 
GeneralRe: stripping out http response header using Regex.Replace Pin
Jayapal Chandran10-Aug-09 7:38
Jayapal Chandran10-Aug-09 7:38 
GeneralRe: stripping out http response header using Regex.Replace Pin
Moreno Airoldi10-Aug-09 7:53
Moreno Airoldi10-Aug-09 7:53 
QuestionNeed to parse GUID Pin
JohnQuar17-Aug-09 7:53
JohnQuar17-Aug-09 7:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.