Windows Develop Bookmark and Share   
 index > Windows Forms General > DateTime Picker-Error
 

DateTime Picker-Error

dtpFromDate & dtpTodate are DateTimepickers and a TextBox txtNoofDays

private void dtpFromDate_ValueChanged(object sender, eventArgs e)
{
double value=Convert.ToDouble(txtNoOfdays.Text);
dtpToDate.Value=dtpFromDate.Value.AddDays(value);
}

Here I got the error at--> //double value ----
Input string was not in correct format

How to resolve It.
uday1302  Tuesday, February 03, 2009 11:56 AM
you get that error if text box is empty, if you want to add nothing if textbox is empty then try

double value = 0;

double.TryParse(txtNoOfdays.Text, out value); // trying to parse if not possible value will remain 0

dtpToDate.Value = dtpFromDate.Value.AddDays(value);


Arjun Paudel
Arjun Paudel  Tuesday, February 03, 2009 12:14 PM
you get that error if text box is empty, if you want to add nothing if textbox is empty then try

double value = 0;

double.TryParse(txtNoOfdays.Text, out value); // trying to parse if not possible value will remain 0

dtpToDate.Value = dtpFromDate.Value.AddDays(value);


Arjun Paudel
Arjun Paudel  Tuesday, February 03, 2009 12:14 PM

You can use google to search for other answers

Custom Search

More Threads

• Windows Media Player Control Box Mimic
• FormClosing Event
• How to get selected radiobutton in a radiogroup
• Finding first textbox in groupbox
• Differenciating between Multiple USB Mice attached to one machine
• Need some help wiring form with a TreeView to a passive view presenter.
• Panel border color?
• GUI Appearance Qualities
• Merging MDI Child and Parent menus
• Advice on Exception Handling