Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7004309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:10:57+00:00 2026-05-27T21:10:57+00:00

I am using Winform And C#. In that i added calander cell in datagridview

  • 0

I am using Winform And C#.

In that i added calander cell in datagridview control using below link code.

It perfectly working.

http://msdn.microsoft.com/en-us/library/7tas5c80.aspx.

My code for calendar control adding….

 foreach (DataGridViewRow row in this.dataGridView2.Rows)
                {
                    row.Cells[4].Value = DateTime.Now;                    
                }

enter image description here

i know MinDate and MaxDate propriety available on normal control.

dateTimePicker1.MinDate = DateTime.Today;

dateTimePicker1.MaxDate = DateTime.Today.AddYears( 1 );

But I want to set min date and max date in all calander control in datagrid view column.

How to implement min and max date in datagridview datetime control for all rows.,

Please help me.,,

Updated Question

 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;
                }
            }

My Code,..

But I am not get MinDate and MaxDate Propriety. What is my mistake…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:10:58+00:00Added an answer on May 27, 2026 at 9:10 pm

    Add new properties to the CalendarColumn class:

    public DateTime MinDate { get; set; }
    public DateTime MaxDate { get; set; }
    

    And in the InitializeEditingControl control, add the following code:

    ctl.MinDate = this.MinDate;
    ctl.MaxDate = this.MaxDate;
    

    You can then set these properties on the column, and they will be reflected in the DateTimePickers (note that it will be taken into account only for new cells)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good morning, I am working on a C# winform application that is using validation
I have a DataGridView that I want to query using Linq (C# WinForm). I
I have a winform project that is using a devexpress layout control and I
I have several controls in a winform application that I added databindings to using
I am using a Datagridview control on winform and a bindingsource for data. Data
I have a web page that is being displaying in a winform app using
I have my winform application gathering data using databinding. Everything looks fine except that
I'm using winforms and I've got a comboBox that represents an IQueryable. Below the
I am using the webbrowser control in winforms and discovered now that background images
I'm working with an n-Tier application using WinForm and WCF Engine Service (Windows Service)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.