Goran Bibic

Goran Bibic

  • 445
  • 2.9k
  • 181k

Remove min and max value datetimepicker

Mar 24 2018 3:42 PM
After put inside this code
 
  1. // don't convert it to datetime (as you said, it may be null)          
  2.  var stringValue = (prijava_radnikaDataGridView.SelectedRows[0].Cells["dataGridViewTextBoxColumn3"].Value);  
  3.   
  4.   
  5.   var dateValue = string.IsNullOrEmpty(Convert.ToString(stringValue)) ? DateTime.MinValue : Convert.ToDateTime("2018-01-01 00:00:00");  
  6.   
  7. // now, datevalue is the new value for datepicker       
  8.    if (string.IsNullOrEmpty(Convert.ToString(stringValue))) vrijemeodjaveDateTimePicker.Value = dateValue; 
 
I have error
 
  1. Activated   Event   Time    Duration    Thread      
  2.     Exception thrown: 'System.ArgumentOutOfRangeException' in System.Windows.Forms.dll ("Value of '1.1.0001. 00:00:00' is not valid for 'Value'. 'Value' should be between 'MinDate' and 'MaxDate'.")   14.33s      [17640] <No Name>  
 

Answers (4)