SegmentedButton
Namespace: Wisej.Web
Assembly: Wisej.Framework (4.2.0.0)
Displays a compact row of exclusive or multiple choices.
- C#
- VB.NET
public class SegmentedButton : Control
Public Class SegmentedButton
Inherits Control
Selection follows segment identity across collection edits. Removing a selected segment clears that selection. Disabled items retain selection and can be selected programmatically. No option is selected automatically. AllowDeselect constrains user activation only; server code may always clear selection.
Example:
var choices = new SegmentedButton { Appearance = SegmentAppearance.Outlined };
choices.Items.Add(new Segment { Text = "1H", Value = 1 });
choices.Items.Add(new Segment { Text = "24H", Value = 24 });
choices.SelectedIndex = 1;
choices.SelectionChanged += (s, e) => MessageBox.Show(choices.SelectedItem?.Text);
Controls.Add(choices);
Constructors
SegmentedButton()
Creates an empty selector with medium raised options.
Properties
AllowDeselect
Boolean: Gets or sets whether user activation may remove the final selection. (Default: False)
Appearance
SegmentAppearance: Gets or sets the raised, outlined, or pill presentation. (Default: Raised)
DefaultSize
Size: Gets the default 300 by 48 pixel size, including room around focused options.
Focusable
Boolean: Gets or sets container focusability. Child options remain focusable. (Default: False)
Items
SegmentCollection: Gets the owned, ordered options. Property edits automatically update the widget.
SegmentSize
SegmentSize: Gets or sets the option padding and minimum height, independently of Control.Size. (Default: Medium)
SelectedIndex
Int32: Gets the first selected index or sets the sole selected option; -1 clears all selection. (Default: -1)
The setter replaces selection even in Multiple mode. Use SetSelected to add or remove individual selections.
SelectedIndices
Int32[]: Gets a snapshot of selected indexes in collection order.
SelectedItem
Segment: Gets the first selected item or sets the sole selected option; null clears selection.
SelectedItems
Segment[]: Gets a snapshot of selected items in collection order.
SelectionMode
SegmentSelectionMode: Gets or sets single or multiple selection. Switching to One retains only the first selected item. (Default: One)
Stretch
Boolean: Gets or sets whether options share the full available width. (Default: False)
TabStop
Boolean: Gets or sets whether the container participates in tab navigation. Child options have their own tab stops. (Default: False)
Methods
Dispose(disposing)
Releases item observation and ownership.
| Parameter | Type | Description |
|---|---|---|
| disposing | Boolean | Whether managed resources are being released. |
OnItemClick(e)
Raises ItemClick, including overrides without subscribers.
| Parameter | Type | Description |
|---|---|---|
| e | SegmentEventArgs | Event data. |
OnSelectedIndexChanged(e)
Raises SelectedIndexChanged, including overrides without subscribers.
| Parameter | Type | Description |
|---|---|---|
| e | EventArgs | Event data. |
OnSelectionChanged(e)
Raises SelectionChanged, including overrides without subscribers.
| Parameter | Type | Description |
|---|---|---|
| e | EventArgs | Event data. |
OnWebEvent(e)
Dispatches client activation independently of event subscription.
| Parameter | Type | Description |
|---|---|---|
| e | WisejEventArgs | Client event. |
OnWebRender(config)
Serializes the option and selection snapshot without application values.
| Parameter | Type | Description |
|---|---|---|
| config | Object | Client configuration. |
ResolveEventItem(e)
Resolves a current enabled client item, rejecting stale and malformed event payloads.
| Parameter | Type | Description |
|---|---|---|
| e | WisejEventArgs | Client event. |
Returns: Segment. The matching item, or null.
SetSelected(index, value)
Adds or removes an individual selection. Selecting in One mode replaces the previous selection.
| Parameter | Type | Description |
|---|---|---|
| index | Int32 | An existing item index. |
| value | Boolean | True selects; false deselects, regardless of AllowDeselect. |
Example:
choices.SelectionMode = SegmentSelectionMode.Multiple;
choices.SetSelected(0, true);
choices.SetSelected(2, true);
ViewChanged()
Requests a new client snapshot after a presentation property changes.
Events
ItemClick
EventHandler<SegmentEventArgs> Occurs after user activation and its selection notifications, if the activated item still exists and is enabled.
SelectedIndexChanged
EventHandler Occurs when the first selected collection index changes.
SelectionChanged
EventHandler Occurs when selected segment identities change.
Inherited By
| Name | Description |
|---|---|
| ChipGroup | Displays wrapping selectable chips with optional counts and close buttons. |
Implements
| Name | Description |
|---|---|
| IUserData | Provides access to the UserData and Tag properties associated to the component implementing this interface. |
| IBindableComponent | Bindable components implement this interface. |
| IDropTarget | Controls that support drag & drop operations implement this interface. |
| IWisejComponent | All wisej components implement this interface. |
| IWisejControl | All wisej controls derived from the Control class must implement this interface. |
| IWisejSerializable | Allows an object to serialize itself. |