xtd 0.2.0
Loading...
Searching...
No Matches
xtd::forms::selection_range Class Reference
Inheritance diagram for xtd::forms::selection_range:
xtd::object

Definition

Represents a date selection range in a month calendar control.

Header
#include <xtd/forms/selection_range>
Namespace
xtd::forms
Library
xtd.forms
Examples
The following example sets the xtd::forms::month_calendar::selection_range property of a xtd::forms::month_calendar control based on two dates entered into two xtd::forms::text_box controls when a xtd::forms::button is clicked. This code assumes new instances of a xtd::forms::month_calendar control, two xtd::forms::text_box controls, and a xtd::forms::button have been created on a xtd::forms::form. You might consider adding code to validate the xtd::forms::control::text assigned to the text boxes to verify that they contain valid dates.
void button1_click(const object& sender, const event_args& e) {
// Set the selection_range with start and end dates from text boxes.
try {
month_calendar1.selection_range(selection_range(date_time::parse(text_box1.text(), date_time::parse(text_box2.text()));
} catch(const system_exception& ex) {
}
}
static date_time parse(const xtd::ustring &s)
Converts the string representation of a date and time to its xtd::date_time equivalent by using the c...
Represents the base class for classes that contain event data, and provides a value to use for events...
Definition event_args.h:18
static dialog_result show()
Displays a message box.
selection_range()=default
Initializes a new instance of the xtd::forms::selection_range class.
Defines the base class for predefined exceptions in the xtd namespace.
Definition system_exception.h:25
virtual const xtd::ustring & message() const noexcept
Gets message associate to the exception.
@ e
The E key.
Remarks
The xtd::forms::selection_range is the date or dates selected and highlighted on the xtd::forms::month_calendar control. If only one date is selected, the xtd::forms::selection_range::start and xtd::forms::selection_range::end property values will be equal. The xtd::forms::selection_range can be changed by the user clicking a date while dragging the mouse pointer across the desired dates, or you can set the range in code. For example, you might want to have the user enter a date range into two xtd::forms::text_box controls or two xtd::forms::date_time_picker controls and set the xtd::forms::selection_range based on those dates.

Public Constructors

 selection_range ()=default
 Initializes a new instance of the xtd::forms::selection_range class.
 
 selection_range (date_time start, date_time end)
 Initializes a new instance of the xtd::forms::selection_range class with the specified beginning and ending dates.
 

Public Properties

virtual date_time end () const noexcept
 Gets the ending date and time of the selection range.
 
virtual selection_rangeend (date_time value)
 Sets the ending date and time of the selection range.
 
virtual date_time start () const noexcept
 Gets the starting date and time of the selection range.
 
virtual selection_rangestart (date_time value)
 Sets the starting date and time of the selection range.
 

Public Methods

xtd::ustring to_string () const noexcept override
 Returns a sxd::ustring that represents the current object.
 

Additional Inherited Members

- Public Member Functions inherited from xtd::object
 object ()=default
 Create a new instance of the ultimate base class object.
 
bool equals (const object &obj) const noexcept
 Determines whether the specified object is equal to the current object.
 
virtual size_t get_hash_code () const noexcept
 Serves as a hash function for a particular type.
 
virtual type_object get_type () const noexcept
 Gets the type of the current instance.
 
template<typename object_t >
std::unique_ptr< object_t > memberwise_clone () const noexcept
 Creates a shallow copy of the current object.
 
- Static Public Member Functions inherited from xtd::object
static bool equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are considered equal.
 
static bool reference_equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are the same instance.
 

Constructor & Destructor Documentation

◆ selection_range() [1/2]

xtd::forms::selection_range::selection_range ( )
default

Initializes a new instance of the xtd::forms::selection_range class.

Remarks
The xtd::forms::selection_range::start and xtd::forms::selection_range::end values are set to xtd::date_time::min_value when this constructor is used.

◆ selection_range() [2/2]

xtd::forms::selection_range::selection_range ( date_time  start,
date_time  end 
)

Initializes a new instance of the xtd::forms::selection_range class with the specified beginning and ending dates.

Parameters
startThe starting date in the xtd::forms::selection_range.
endThe ending date in the xtd::forms::selection_range.
Remarks
If the lower xtd::dateTime value is greater than the upper xtd::date_time value, the lower value will be assigned to the xtd::forms::selection_range::end property instead of the xtd::forms::selection_range::start property.

Member Function Documentation

◆ end() [1/2]

virtual date_time xtd::forms::selection_range::end ( ) const
virtualnoexcept

Gets the ending date and time of the selection range.

Returns
The ending xtd::date_time value of the range.

◆ end() [2/2]

virtual selection_range & xtd::forms::selection_range::end ( date_time  value)
virtual

Sets the ending date and time of the selection range.

Parameters
valueThe ending xtd::date_time value of the range.
Returns
This current instance.

◆ start() [1/2]

virtual date_time xtd::forms::selection_range::start ( ) const
virtualnoexcept

Gets the starting date and time of the selection range.

Returns
The starting xtd::date_time value of the range.

◆ start() [2/2]

virtual selection_range & xtd::forms::selection_range::start ( date_time  value)
virtual

Sets the starting date and time of the selection range.

Parameters
valueThe starting xtd::date_time value of the range.
Returns
This current instance.

◆ to_string()

xtd::ustring xtd::forms::selection_range::to_string ( ) const
overridevirtualnoexcept

Returns a sxd::ustring that represents the current object.

Returns
A string that represents the current object.
Examples
The following code example demonstrates what to_string returns.

Reimplemented from xtd::object.


The documentation for this class was generated from the following file: