title: How to set mindate and maxdate in winform Datagridview datetime picker Control?
body: <p>I am using Winform And C#.</p>
  
  <p>In that i added calander cell in datagridview control using below link code.</p>
  
  <p>It perfectly working.</p>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/7tas5c80.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/7tas5c80.aspx</a>.</p>
  
  <p>My code for calendar control adding....</p>
  
  <pre><code> foreach (DataGridViewRow row in this.dataGridView2.Rows)
                  {
                      row.Cells[4].Value = DateTime.Now;                    
                  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/JTBrM.png" alt="enter image description here"></p>
  
  <p>i know MinDate and MaxDate propriety available on normal control.</p>
  
  <pre><code>dateTimePicker1.MinDate = DateTime.Today;
  
  dateTimePicker1.MaxDate = DateTime.Today.AddYears( 1 );
  </code></pre>
  
  <p>But I want to set min date and max date in all calander control in datagrid view column.</p>
  
  <p>How to implement min and max date in datagridview datetime control for all rows.,</p>
  
  <p>Please help me.,,</p>
  
  <p>Updated Question</p>
  
  <pre><code> public class CalendarCell : DataGridViewTextBoxCell
          {
  
              public CalendarCell()
                  : base()
              {
                  // Use the short date format.
                  this.Style.Format = "d";
              }
  
              // For Min And Max DATE
              public DateTime MaxDate { get; set; }
              public DateTime MinDate { get; set; }
  
              public override void InitializeEditingControl(int rowIndex, object
                  initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
              {
                  // Set the value of the editing control to the current cell value.
                  base.InitializeEditingControl(rowIndex, initialFormattedValue,
                      dataGridViewCellStyle);
                  CalendarEditingControl ctl =
                      DataGridView.EditingControl as CalendarEditingControl;
  
                  // For Min And Max DATE
                  ctl.MinDate = MinDate;
                  ctl.MaxDate = MaxDate;
  
                  // Use the default row value when Value property is null.
                  if (this.Value == null)
                  {
                      ctl.Value = (DateTime)this.DefaultNewRowValue;
                  }
                  else
                  {
                      ctl.Value = (DateTime)this.Value;
                  }
              }
  </code></pre>
  
  <p>My Code,..</p>
  
  <p>But I am not get MinDate and MaxDate Propriety. What is my mistake... </p>