SelectionRange Constructor (DateTime, DateTime)
.NET Framework (current version)
Initializes a new instance of the SelectionRange class with the specified beginning and ending dates.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Parameters
- lower
-
Type:
System::DateTime
The starting date in the SelectionRange.
- upper
-
Type:
System::DateTime
The ending date in the SelectionRange.
The following example sets the SelectionRange property of a MonthCalendar control based on two dates entered into two TextBox controls when a Button is clicked. This code assumes new instances of a MonthCalendar control, two TextBox controls, and a Button have been created on a Form. You might consider adding code to validate the Text assigned to the text boxes to verify that they contain valid dates.
private: void button1_Click( Object^ sender, EventArgs^ e ) { // Set the SelectionRange with start and end dates from text boxes. try { monthCalendar1->SelectionRange = gcnew SelectionRange( DateTime::Parse( textBox1->Text ), DateTime::Parse( textBox2->Text ) ); } catch ( Exception^ ex ) { MessageBox::Show( ex->Message ); } }
.NET Framework
Available since 1.1
Available since 1.1
Show:
