Table of Contents

Class ListControl<TItem>

Namespace
Alternet.UI
Assembly
Alternet.UI.Common.dll

Provides a common implementation of members for the ListBox, ComboBox and other controls.

public abstract class ListControl<TItem> : Control, IBaseObjectWithId, IDisposableObject, IBaseObject, ISupportInitialize, IFocusable, ITextProperty, IComponent, INotifyDataErrorInfo, IReadOnlyStrings, IListControl<TItem>, IControl, IDisposable, IWin32Window where TItem : class, new()

Type Parameters

TItem

Type of the item. Can be object, ListControlItem or any other type.

Inheritance
ListControl<TItem>
Implements
Derived

Properties

Count

Gets the number of elements contained in the control.

FirstItem

Gets first item in the control or null if there are no items.

this[int]

Gets or sets the element at the specified index.

this[long]

Gets or sets the Items element at the specified index.

this[int?]

Gets the element at the specified index.

Items

Gets or sets the items of the control.

LastItem

Gets last item in the control or null if there are no items.

LastRootItem

Gets last root item in the control or null if there are no items.

Search

Gets or sets string search provider.

SelectedAction

Returns Action associated with the SelectedItem if it is ListControlItem.

SelectedIndex

Gets or sets the zero-based index of the currently selected item in the control.

SelectedIndexAsInt

Gets or sets the zero-based index of the currently selected item in the control. Same as SelectedIndex but is not nullable.

SelectedItem

Gets or sets the currently selected item in the control.

SelectedUniqueId

Returns ObjectUniqueId associated with the SelectedItem if it is ListControlItem.

Methods

Add(TItem)

Adds an object to the end of the Items collection.

AttachItems(IListControlItems<TItem>?)

Called when items are attached to the control.

ClearSelected()

Unselects all items in the control.

DetachItems(IListControlItems<TItem>?)

Called when items are detached to the control.

FindString(string?)

Returns the index of the first item in the control that starts with the specified string.

FindString(string?, int?)

Returns the index of the first item in the control beyond the specified index that contains the specified string. The search is not case sensitive.

FindStringEx(string?, int?, bool, bool)

Returns the index of the first item in the control beyond the specified index that contains or equal the specified string.

FindStringExact(string?)

Finds the first item in the combo box that matches the specified string.

GetItem(int)

Gets item with the specified index. This methods is called from all other methods that request the item.

GetItemText(int, bool)

Returns the text representation of item with the specified index.

GetItemText(TItem?, bool)

Returns the text representation of the specified item.

ItemsAsText(IReadOnlyList<int>, string?)

Gets items as string.

ItemsCollectionChanged(object?, NotifyCollectionChangedEventArgs)

Callback which is called when items are changed in the control.

RecreateItems(ListControlItems<TItem>?)

Recreates items. Before calling this method, you need to unbind all events connected to the Items.

RemoveAll()

Removed all items from the control.

RemoveItemWithValue(object?)

Removes item with the specified value. Item is removed if it equals the specified value or if it is ListControlItem and it's Value property equals the value.

RemoveItemWithValueIf(object?, bool)

Same as RemoveItemWithValue(object?), but checks for the condition before removing the item.

RemoveItems(IReadOnlyList<int>)

Removes items from the control.

RequiredItem(int)

Gets ListControlItem item with the specified index. If index of the item is invalid, an exception is thrown.

RequiredItem<T>(int)

Gets item with the specified index. If index of the item is invalid, throws an exception.

SafeItem(int)

Gets ListControlItem item with the specified index. If index of the item is invalid or item is not ListControlItem, returns null.

SafeItem<T>(int)

Gets item with the specified index. If index of the item is invalid, returns null.

SafeItems()

Gets items.

SelectFirstItem()

Selects first item in the control.

SelectLastItem()

Selects last item in the control.

SelectedItemAs<T>()

Casts selected item to T type.

SetCount(int, Func<TItem>)

Changes the number of elements in the Items.

SetItem(int, TItem)

Sets item with the specified index. This methods is called from all other methods that change the item.

SetSelectedIndex(int?)

Sets SelectedIndex. Implemented as method for the convenience.

Events

CustomItemText

Occurs when controls needs to get string representation of the item for the display or other purposes. Called from GetItemText(int, bool).