HtmlOptionsCollection Class

https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#htmloptionscollection

public sealed class HtmlOptionsCollection : HtmlCollection
Inheritance
HtmlCollection HtmlOptionsCollection

Properties

NameDescription
Lengthhttps://html.spec.whatwg.org/multipage/common-dom-interfaces.html#dom-htmloptionscollection-length
SelectedIndexGets or sets the index of the first selected option, or -1 when no option is selected.

https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#dom-htmloptionscollection-length

public new uint Length { get; set; }

SelectedIndex

SelectElements.cs

Gets or sets the index of the first selected option, or -1 when no option is selected.

public int SelectedIndex { get; set; }

Indexers

NameDescription
this[uint]The indexed setter (https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#dom-htmloptionscollection-setter).

The indexed setter (https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#dom-htmloptionscollection-setter).

public new HtmlOptionElement? this[uint index] { get; set; }

Methods

NameDescription
Add(HtmlElement, HtmlElement?)https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#dom-htmloptionscollection-add
Add(HtmlElement, int)Inserts an option or optgroup element before the option at the given index, or at the end when the index is invalid.
Remove(int)https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#dom-htmloptionscollection-remove

Add overloads

Add(HtmlElement, HtmlElement?)

SelectElements.cs

https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#dom-htmloptionscollection-add

public void Add(HtmlElement element, HtmlElement? before = null)

Add(HtmlElement, int)

SelectElements.cs

Inserts an option or optgroup element before the option at the given index, or at the end when the index is invalid.

public void Add(HtmlElement element, int before)

https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#dom-htmloptionscollection-remove

public void Remove(int index)