xtd 1.0.0
Loading...
Searching...
No Matches
xtd::forms::control::control_collection Class Reference
Inheritance diagram for xtd::forms::control::control_collection:
xtd::forms::layout::arranged_element_collection< xtd::forms::control_ref > xtd::object xtd::collections::generic::icollection< type_t > xtd::collections::generic::ienumerable< type_t > xtd::collections::generic::extensions::collection_common< type_t, icollection< type_t > > xtd::interface xtd::collections::generic::ienumerable_abstract xtd::collections::generic::extensions::enumerable_iterators< type_t, xtd::collections::generic::ienumerable< type_t > > xtd::collections::generic::extensions::enumerable< ienumerable< type_t >, type_t >

Definition

Represents a collection of controls.

Public Aliases

using base
 Represents the base type of the collection.

Public Constructors

 control_collection ()=default
 Creates a new object xtd::forms::control::control_collection with specified allocator (optional).

Operators

auto operator[] (const xtd::string &name) const -> value_type
 Gets the first xtd::forms::control::control_collection in the list with the specified name.
auto operator[] (const xtd::string &name) -> value_type
 Gets the first xtd::forms::control::control_collection in the list with the specified name.

Public Methods

auto add (const xtd::forms::control_ref &value) -> void override
template<typename control_t>
auto add (control_t &value) -> void
template<typename control_t>
auto add_new () -> control_t &
 Creates and adds a control to the end.
template<typename control_t, typename ... args_t>
auto add_new (args_t &&...args) -> control_t &
 Creates and adds a control to the end.
auto insert (xtd::usize index, const xtd::forms::control_ref &value) -> void override
 Inserts specified element at specified index.
template<typename control_t>
auto insert (xtd::usize index, control_t &value) -> void
template<typename control_t>
auto insert_new (xtd::usize index) -> control_t &
 Creates and inserts specified control at specified position.
template<typename control_t, typename ... args_t>
auto insert_new (xtd::usize index, args_t &&...args) -> control_t &
 Creates and inserts specified control at specified position.

Public Deprecated Methods

template<typename control_t>
auto push_back (control_t &value) -> void

Protected Methods

auto on_item_removed (xtd::usize index, xtd::forms::control_ref &item) -> void override
 Raises the xtd::forms::layout::arranged_element_collection::item_removed event.

Additional Inherited Members

using base_type
 Represents the list base type.
using const_base_type
 Represents the list base type.
using size_type
 Represents the list size type (usually xtd::usize).
using reference
 Represents the reference of list value type.
using const_reference
 Represents the const reference of list value type.
using pointer
 Represents the pointer of list value type.
using const_pointer
 Represents the const pointer of list value type.
using read_only_collection
 Represents the read only collection of of list.
using reverse_iterator
 Represents the reverse iterator type of the collection.
using const_reverse_iterator
 Represents the const reverse iterator type of the collection.
using value_type
 Represents the xtd::collections::generic::icollection value type.
using value_type
 Represents the xtd::collections::generic::ienumerable value type.
using iterator
 Represents the iterator of xtd::collections::generic::ienumerable value type.
using const_iterator
 Represents the const iterator of xtd::collections::generic::ienumerable value type.
using iterator
 Represents the iterator of enumerable value type.
using const_iterator
 Represents the const iterator of enumerable value type.
using enumerable_type
 Represents the ienumerable enumerable type.
using source_type
 Represents the ienumerable source type.
using ienumerable
 Represents the ienumerable value type.
using list
 Represents the list value type.
event< arranged_element_collection, delegate< void(xtd::usize, xtd::forms::control_ref &item)> > item_added
 Occurs when an item is added to the collection.
event< arranged_element_collection, delegate< void(xtd::usize, xtd::forms::control_ref &item)> > item_updated
 Occurs when an item is updated in the collection.
event< arranged_element_collection, delegate< void(xtd::usize, xtd::forms::control_ref &item)> > item_removed
 Occurs when an item is removed from the collection.
static constexpr xtd::usize npos
 Represents a value that is not a valid position in a collection.
static constexpr xtd::usize bpos
 Represents the index of the first valid element in a collection.
static constexpr xtd::usize epos
 Represents the index of the last valid element in a collection.
 arranged_element_collection ()=default
 Initializes a new instance of the xtd::forms::layout::arranged_element_collection class that is empty.
 arranged_element_collection (size_type capacity)
 Constructs the container with specified count default-inserted instances of type_t. No copies are made.
 arranged_element_collection (const xtd::collections::generic::ienumerable< xtd::forms::control_ref > &collection)
 Initializes a new instance of the xtd::forms::layout::arranged_element_collection <type_t> class that contains elements copied from the specified collection and has sufficient capacity to accommodate the number of elements copied.
 arranged_element_collection (const arranged_element_collection &collection)
 Default copy constructor with specified list.
 arranged_element_collection (arranged_element_collection &&collection)
 Move constructor with specified list.
 arranged_element_collection (const base_type &collection)
 Copy constructor with specified base type list.
 arranged_element_collection (base_type &&collection)
 Move constructor with specified base type list.
 arranged_element_collection (std::initializer_list< xtd::forms::control_ref > items)
 Constructs the container with the contents of the specified initializer list, and allocator.
 arranged_element_collection (input_iterator_t first, input_iterator_t last)
 Constructs the container with the contents of the range [first, last).
auto capacity () const noexcept -> size_type
 Gets the total number of elements the internal data structure can hold without resizing.
auto capacity (size_type value) -> void
 Sets the total number of elements the internal data structure can hold without resizing.
auto count () const noexcept -> size_type override
 Gets the number of elements contained in the xtd::forms::layout::arranged_element_collection <type_t>.
auto data () -> pointer
 Direct access to the underlying array.
auto data () const -> const_pointer
 Direct access to the underlying array.
const auto & items () const
 Returns the underlying base type items.
auto & items ()
 Returns the underlying base type items.
virtual auto sorted () const noexcept -> bool
 Checks whether the container is sorted.
virtual auto sorted (bool value) -> arranged_element_collection &
 Sets the container is sorted.
auto add (const xtd::forms::control_ref &item) -> void override
 Adds an item to the xtd::forms::layout::arranged_element_collection <type_t>.
virtual auto add (xtd::forms::control_ref &&item) -> void
 Adds an item to the xtd::forms::layout::arranged_element_collection <type_t>.
virtual auto add_range (const arranged_element_collection &collection) -> void
 Adds elements to the end.
virtual auto add_range (const std::vector< xtd::forms::control_ref > &collection) -> void
 Adds elements to the end.
virtual auto add_range (const std::initializer_list< xtd::forms::control_ref > &collection) -> void
 Adds elements to the end.
auto add_range (collection_t &&collection) -> void
 Adds elements to the end.
auto add_range (const collection_t &collection) -> void
 Adds elements to the end.
auto clear () -> void override
 Removes all items from the xtd::forms::layout::arranged_element_collection <type_t>.
auto contains (const xtd::forms::control_ref &item) const noexcept -> bool override
 Determines whether the xtd::forms::layout::arranged_element_collection <type_t> contains a specific value.
auto copy_to (xtd::array< xtd::forms::control_ref > &array, xtd::usize array_index) const -> void override
 Copies the elements of the xtd::forms::layout::arranged_element_collection <type_t> to an xtd::array, starting at a particular xtd::array index.
auto get_enumerator () const noexcept -> xtd::collections::generic::enumerator< xtd::forms::control_ref > override
 Returns an enumerator that iterates through the xtd::forms::layout::arranged_element_collection <type_t>.
virtual auto sort () -> arranged_element_collection &
 Sorts the content.
auto remove (const xtd::forms::control_ref &item) -> bool override
 Removes the first occurrence of a specific object from the xtd::forms::layout::arranged_element_collection <type_t>.
virtual auto remove_at (xtd::usize index) -> void
 Erases element at specified index.
auto reverse () -> arranged_element_collection &
 Reverses the order of the elements in the entire xtd::collections::generic::list <type_t>.
auto reverse (size_type index, size_type count) -> arranged_element_collection &
 Reverses the order of the elements in the specified range.
auto to_array () const noexcept -> xtd::array< xtd::forms::control_ref >
 Gets an array with the elements of the container.
auto operator= (const arranged_element_collection &other) -> arranged_element_collection &
 Copy assignment operator. Replaces the contents with a copy of the contents of other.
auto operator= (arranged_element_collection &&other) noexcept -> arranged_element_collection &
 Move assignment operator. Replaces the contents with those of other using move semantics (i.e. the data in other is moved from other into this container). other is in a valid but unspecified state afterwards.
auto operator= (const std::initializer_list< xtd::forms::control_ref > &items) -> arranged_element_collection &
 Replaces the contents with those identified by initializer list ilist.
auto operator[] (size_type index) -> value_type &
 Access specified element.
auto operator[] (size_type index) const -> const value_type &
 Access specified element.
 operator const_base_type & () const noexcept
 Returns a reference to the underlying base type.
 operator base_type & () noexcept
 Returns a reference to the underlying base type.
auto operator== (const arranged_element_collection &value) const -> bool
auto operator!= (const arranged_element_collection &value) const -> bool
auto max_size () const noexcept -> size_type
 Returns the maximum possible number of elements.
auto at (size_type pos) -> reference
 Access specified element with bounds checking.
auto at (size_type pos) const -> const_reference
 Access specified element with bounds checking.
auto back () -> reference
 Access the last element.
auto back () const -> const_reference
 Access the last element.
auto crbegin () const noexcept -> const_reverse_iterator
 Returns a reverse iterator to the end.
auto crend () const noexcept -> const_reverse_iterator
 Returns a reverse iterator to the end.
auto front () -> reference
 Access the first element.
auto front () const -> const_reference
 Access the first element.
auto get_allocator () const noexcept
 Returns the associated allocator.
auto emplace (xtd::collections::generic::list< value_type >::const_iterator pos, args_t &&... args) -> void
 Inserts specified element at specified position.
auto emplace_back (args_t &&... args) -> void
 Adds an element to the end.
auto erase (xtd::collections::generic::list< value_type >::iterator pos)
 Erases element at specified position.
auto erase (xtd::collections::generic::list< value_type >::const_iterator pos)
 Erases element at specified position.
auto erase (xtd::collections::generic::list< value_type >::iterator first, xtd::collections::generic::list< value_type >::iterator last)
 Erases elements at specified range.
auto erase (xtd::collections::generic::list< value_type >::const_iterator first, xtd::collections::generic::list< value_type >::const_iterator last)
 Erases elements at specified range.
auto erase_at (xtd::usize index) -> void
 Erases element at specified index.
auto insert (xtd::collections::generic::list< value_type >::const_iterator pos, const xtd::forms::control_ref &value)
 Inserts specified element at specified position.
auto insert (xtd::collections::generic::list< value_type >::const_iterator pos, xtd::forms::control_ref &&value)
 Inserts specified element at specified position.
auto insert_at (xtd::usize index, const xtd::forms::control_ref &value) -> void
 Inserts specified element at specified index.
auto pop_back () -> void
 Removes the last element of the container.
auto push_back (const xtd::forms::control_ref &item) -> void
 Adds an element to the end.
auto push_back (xtd::forms::control_ref &&item) -> void
 Adds an element to the end.
auto push_back_range (const arranged_element_collection &collection) -> void
 Adds elements to the end.
auto push_back_range (const std::vector< xtd::forms::control_ref > &collection) -> void
 Adds elements to the end.
auto push_back_range (const std::initializer_list< xtd::forms::control_ref > &collection) -> void
 Adds elements to the end.
auto push_back_range (collection_t &&collection) -> void
 Adds elements to the end.
auto push_back_range (iterator_t begin, iterator_t end) -> void
 Adds elements to the end.
auto to_vector () const noexcept -> std::vector< xtd::forms::control_ref >
 Gets an array with the elements of the container.
auto rbegin () noexcept
 Returns a reverse iterator to the end.
auto rbegin () const noexcept
 Returns a reverse iterator to the end.
auto rend () noexcept
 Returns a reverse iterator to the end.
auto rend () const noexcept
 Returns a reverse iterator to the end.
auto reserve (size_type size) -> void
 Reserves storage.
auto shrink_to_fit () -> void
 Reduces memory usage by freeing unused memory.
 object ()=default
 Create a new instance of the ultimate base class object.
virtual auto equals (const object &obj) const noexcept -> bool
 Determines whether the specified object is equal to the current object.
virtual auto get_hash_code () const noexcept -> xtd::usize
 Serves as a hash function for a particular type.
virtual auto get_type () const noexcept -> type_object
 Gets the type of the current instance.
template<typename object_t>
auto memberwise_clone () const -> xtd::unique_ptr_object< object_t >
 Creates a shallow copy of the current object.
virtual auto to_string () const -> xtd::string
 Returns a xtd::string that represents the current object.
virtual auto add (const type_t &item) -> void=0
 Adds an item to the xtd::collections::generic::icollection <type_t>.
virtual auto contains (const type_t &item) const noexcept -> bool=0
 Determines whether the xtd::collections::generic::icollection <type_t> contains a specific value.
virtual auto copy_to (xtd::array< type_t > &array, xtd::usize array_index) const -> void=0
 Copies the elements of the xtd::collections::generic::icollection <type_t> to an xtd::array, starting at a particular xtd::array index.
virtual auto remove (const type_t &item) -> bool=0
 Removes the first occurrence of a specific object from the xtd::collections::generic::icollection <type_t>.
virtual auto begin () const -> const_iterator
 Returns an iterator to the first element of the enumerable.
virtual auto cbegin () const -> const_iterator
 Returns an iterator to the first element of the enumerable.
virtual auto cend () const -> const_iterator
 Returns an iterator to the element following the last element of the enumerable.
virtual auto end () const -> const_iterator
 Returns an iterator to the element following the last element of the enumerable.
auto aggregate (const std::function< type_t(const type_t &, const type_t &)> &funcfunc) const -> type_t
 Applies an accumulator function over a sequence.
auto all (const std::function< bool(const type_t &)> &predicatepredicate) const -> bool
 Determines whether all elements of a sequence satisfy a condition.
auto any () const noexcept -> bool
 Determines whether a sequence contains any elements.
auto append (const type_t &element) const noexcept
 Appends a value to the end of the sequence.
auto as_enumerable () const noexcept
 Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
auto average () const noexcept
 Computes the average of a sequence of source_t values.
auto cast () const noexcept
 Casts the elements of an xtd::collections::generic::ienumerable to the specified type.
auto chunk (xtd::usize size) const
 Splits the elements of a sequence into chunks of size at most size.
auto concat (const ienumerable< type_t > &second) const noexcept
 Concatenates two sequences.
auto contains (const type_t &value) const noexcept -> bool
 Determines whether a sequence contains a specified element by using the default equality comparer.
auto count () const noexcept -> xtd::usize
 Returns the number of elements in current sequence.
auto count_by (const std::function< key_t(const type_t &)> &key_selector) const noexcept
 Returns the count of elements in the current sequence grouped by key.
auto default_if_empty () const noexcept
 Returns the elements of the specified sequence or the type parameter's default value in a singleton collection if the current sequence is empty.
auto distinct () const noexcept
 Returns distinct elements from a sequence by using the default equality comparer to compare values.
auto first_or_default (const std::function< bool(const type_t &)> &predicatepredicate, const type_t &default_value) const noexcept -> type_t
 Returns the first element of the sequence that satisfies a condition, or a specified default value if no such element is found.
auto order () const
 Sorts the elements of a sequence in ascending order.
auto order_by (const std::function< type_t(const type_t &)> &key_selector) const
 Sorts the elements of a sequence in ascending order according to a key.
auto order_by_descending (const std::function< key_t(const type_t &)> &key_selector) const
 Sorts the elements of a sequence in descending order according to a key.
auto select (auto &&selector) const
 Projects each element of a sequence into a new form.
auto to_array () const noexcept -> xtd::array< type_t >
 Creates a xtd::array <type_t> from an xtd::collections::generic::ienumerable <type_t>.
auto to_list () const noexcept -> xtd::collections::generic::list< type_t >
 Creates a xtd::collections::generic::list <type_t> from an xtd::collections::generic::ienumerable <type_t>.
auto where (auto &&predicatepredicate) const
 Filters a sequence of values based on a predicate.
virtual auto empty () const noexcept -> bool
 Checks whether the container is empty.
virtual auto size () const noexcept -> xtd::usize
 Gets the number of elements contained in the xtd::collections::generic::icollection <type_t>.
virtual auto operator<< (const type_t &item) -> icollection< type_t > &
 The shift left operator adds an item to the xtd::collections::generic::icollection <type_t>.
virtual auto operator>> (const type_t &item) -> icollection< type_t > &
 The shift right operator removes the first occurrence of a specific object from the xtd::collections::generic::icollection <type_t>.
template<typename object_a_t, typename object_b_t>
static auto equals (const object_a_t &object_a, const object_b_t &object_b) noexcept -> bool
 Determines whether the specified object instances are considered equal.
template<typename object_a_t, typename object_b_t>
static auto reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept -> bool
 Determines whether the specified object instances are the same instance.
static auto to_const_iterator (typename source_collection_t::const_iterator &value, const source_collection_t &source_collection, const target_collection_t &target_collection) noexcept -> typename target_collection_t::const_iterator
 Converts source iterator to target iterator.
static auto to_iterator (typename source_collection_t::const_iterator &value, const source_collection_t &source_collection, const target_collection_t &target_collection) noexcept -> typename target_collection_t::const_iterator
 Converts source iterator to target iterator.
virtual auto on_item_added (xtd::usize index, xtd::forms::control_ref &item) -> void
 Raises the xtd::forms::layout::arranged_element_collection::item_added event.
virtual auto on_item_updated (xtd::usize index, xtd::forms::control_ref &item) -> void
 Raises the xtd::forms::layout::arranged_element_collection::item_updated event.

Member Typedef Documentation

◆ base

Represents the base type of the collection.

Constructor & Destructor Documentation

◆ control_collection()

xtd::forms::control::control_collection::control_collection ( )
explicitdefault

Creates a new object xtd::forms::control::control_collection with specified allocator (optional).

Remarks
If allocator not specified, the std::allocator<value_type> is used.

Member Function Documentation

◆ operator[]() [1/2]

auto xtd::forms::control::control_collection::operator[] ( const xtd::string & name) const -> value_type
nodiscard

Gets the first xtd::forms::control::control_collection in the list with the specified name.

Parameters
nameThe name of the xtd::forms::control to get from the list.
Returns
The first xtd::forms::control in the list with the given Name. This item returns optional with no value if no xtd::forms::control with the given name can be found.
Remarks
The operator [] property is case-sensitive when searching for names. That is, if two controls exist with the names "Lname" and "lname", operator [] property will find only the xtd::forms::control with the xtd::forms::control::name() that you specify, not both.

◆ operator[]() [2/2]

auto xtd::forms::control::control_collection::operator[] ( const xtd::string & name) -> value_type
nodiscard

Gets the first xtd::forms::control::control_collection in the list with the specified name.

Parameters
nameThe name of the xtd::forms::control to get from the list.
Returns
The first xtd::forms::control in the list with the given Name. This item returns optional with no value if no xtd::forms::control with the given name can be found.
Remarks
The operator [] property is case-sensitive when searching for names. That is, if two controls exist with the names "Lname" and "lname", operator [] property will find only the xtd::forms::control with the xtd::forms::control::name() that you specify, not both.

◆ add_new() [1/2]

template<typename control_t>
auto xtd::forms::control::control_collection::add_new ( ) -> control_t &
inline

Creates and adds a control to the end.

Returns
A reference to the created control.
Remarks
The control will be destroyed automatically when the control no longer has a parent.
For creation and insertion, this method uses the xtd::forms::control::create methods of the various controls.
Examples
The folowing example demonstartes the use of xtd::forms::control::control_collection::add_new, and xtd::forms::control::control_collection::insert_new methods.
#include <xtd/xtd>
auto main() -> int {
auto button1_clicked = 0, button2_clicked = 0;
auto form1 = form::create("Emplace example");
form1.controls().insert_new<button>(0, "Button 1", point{50, 50})
.click += delegate_ {form1.controls()["label1"].get().text(string::format("Button 1 clicked {} times", ++button1_clicked));};
form1.controls().insert_new<button>(1, "Button 2", point {50, 100}, size {200, 75})
.auto_repeat(true)
.click += delegate_ {form1.controls()["label2"].get().text(string::format("Button 2 clicked {} times", ++button2_clicked));};
form1.controls().add_new<label>("Button 1 clicked 0 times", point {50, 200}, size {200, 23}, "label1");
form1.controls().add_new<label>("Button 2 clicked 0 times", point {50, 230}, size {200, 23}, "label2");
application::run(form1);
}
Represents a Windows button control.
Definition button.hpp:49
xtd::event< control, xtd::event_handler > click
Occurs when the xtd::forms::control is clicked.
Definition control.hpp:1476
static auto create() -> form
A factory to create an xtd::forms::form.
static auto format(const basic_string< char > &fmt, args_t &&... args) -> basic_string
#define delegate_
The declaration of a delegate type is similar to a method signature. It has a return value and any nu...
Definition delegate.hpp:1018
xtd::forms::style_sheets::control label
The label data allows you to specify the box of a label control.
Definition label.hpp:25
@ point
Specifies a printer's point (1/72 inch) as the unit of measure.
Definition graphics_unit.hpp:25
constexpr auto size() const noexcept -> size_type
Returns the number of elements.
Definition read_only_span.hpp:217

◆ add_new() [2/2]

template<typename control_t, typename ... args_t>
auto xtd::forms::control::control_collection::add_new ( args_t &&... args) -> control_t &
inline

Creates and adds a control to the end.

Parameters
argsThe arguments to forward to the create method of the control
Returns
A reference to the created control.
Remarks
The control will be destroyed automatically when the control no longer has a parent.
For creation and insertion, this method uses the xtd::forms::control::create methods of the various controls.
Examples
The folowing example demonstartes the use of xtd::forms::control::control_collection::add_new, and xtd::forms::control::control_collection::insert_new methods.
#include <xtd/xtd>
auto main() -> int {
auto button1_clicked = 0, button2_clicked = 0;
auto form1 = form::create("Emplace example");
form1.controls().insert_new<button>(0, "Button 1", point{50, 50})
.click += delegate_ {form1.controls()["label1"].get().text(string::format("Button 1 clicked {} times", ++button1_clicked));};
form1.controls().insert_new<button>(1, "Button 2", point {50, 100}, size {200, 75})
.auto_repeat(true)
.click += delegate_ {form1.controls()["label2"].get().text(string::format("Button 2 clicked {} times", ++button2_clicked));};
form1.controls().add_new<label>("Button 1 clicked 0 times", point {50, 200}, size {200, 23}, "label1");
form1.controls().add_new<label>("Button 2 clicked 0 times", point {50, 230}, size {200, 23}, "label2");
application::run(form1);
}

◆ insert()

auto xtd::forms::control::control_collection::insert ( xtd::usize index,
const xtd::forms::control_ref & value ) -> void
overridevirtual

Inserts specified element at specified index.

Parameters
indexThe index before which the content will be inserted.
valueThe element to insert.

Reimplemented from xtd::forms::layout::arranged_element_collection< xtd::forms::control_ref >.

◆ insert_new() [1/2]

template<typename control_t>
auto xtd::forms::control::control_collection::insert_new ( xtd::usize index) -> control_t &
inline

Creates and inserts specified control at specified position.

Parameters
indexThe index before which the content will be inserted.
argsThe arguments to forward to the create method of the control
Returns
A reference to the created control.
Remarks
The control will be destroyed automatically when the control no longer has a parent.
For creation and insertion, this method uses the xtd::forms::control::create methods of the various controls.
Examples
The folowing example demonstartes the use of xtd::forms::control::control_collection::add_new, and xtd::forms::control::control_collection::insert_new methods.
#include <xtd/xtd>
auto main() -> int {
auto button1_clicked = 0, button2_clicked = 0;
auto form1 = form::create("Emplace example");
form1.controls().insert_new<button>(0, "Button 1", point{50, 50})
.click += delegate_ {form1.controls()["label1"].get().text(string::format("Button 1 clicked {} times", ++button1_clicked));};
form1.controls().insert_new<button>(1, "Button 2", point {50, 100}, size {200, 75})
.auto_repeat(true)
.click += delegate_ {form1.controls()["label2"].get().text(string::format("Button 2 clicked {} times", ++button2_clicked));};
form1.controls().add_new<label>("Button 1 clicked 0 times", point {50, 200}, size {200, 23}, "label1");
form1.controls().add_new<label>("Button 2 clicked 0 times", point {50, 230}, size {200, 23}, "label2");
application::run(form1);
}

◆ insert_new() [2/2]

template<typename control_t, typename ... args_t>
auto xtd::forms::control::control_collection::insert_new ( xtd::usize index,
args_t &&... args ) -> control_t &
inline

Creates and inserts specified control at specified position.

Parameters
indexThe index before which the content will be inserted.
argsThe arguments to forward to the create method of the control
Returns
A reference to the created control.
Remarks
The control will be destroyed automatically when the control no longer has a parent.
For creation and insertion, this method uses the xtd::forms::control::create methods of the various controls.
Examples
The folowing example demonstartes the use of xtd::forms::control::control_collection::add_new, and xtd::forms::control::control_collection::insert_new methods.
#include <xtd/xtd>
auto main() -> int {
auto button1_clicked = 0, button2_clicked = 0;
auto form1 = form::create("Emplace example");
form1.controls().insert_new<button>(0, "Button 1", point{50, 50})
.click += delegate_ {form1.controls()["label1"].get().text(string::format("Button 1 clicked {} times", ++button1_clicked));};
form1.controls().insert_new<button>(1, "Button 2", point {50, 100}, size {200, 75})
.auto_repeat(true)
.click += delegate_ {form1.controls()["label2"].get().text(string::format("Button 2 clicked {} times", ++button2_clicked));};
form1.controls().add_new<label>("Button 1 clicked 0 times", point {50, 200}, size {200, 23}, "label1");
form1.controls().add_new<label>("Button 2 clicked 0 times", point {50, 230}, size {200, 23}, "label2");
application::run(form1);
}

◆ on_item_removed()

auto xtd::forms::control::control_collection::on_item_removed ( xtd::usize index,
xtd::forms::control_ref & item ) -> void
inlineoverrideprotectedvirtual

Raises the xtd::forms::layout::arranged_element_collection::item_removed event.

Parameters
indexThe index of the item.
itemThe item removed.

Reimplemented from xtd::forms::layout::arranged_element_collection< xtd::forms::control_ref >.


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