AngleSharp by AngleSharp

<PackageReference Include="AngleSharp" Version="0.9.10" />

.NET API 1,230,336 bytes

 HtmlTableRowElement

Represents the HTML tr element.
using AngleSharp.Dom.Collections; using AngleSharp.Dom.Css; using AngleSharp.Dom.Events; using AngleSharp.Extensions; using AngleSharp.Html; namespace AngleSharp.Dom.Html { internal sealed class HtmlTableRowElement : HtmlElement, IHtmlTableRowElement, IHtmlElement, IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildNode, IElementCssInlineStyle, IGlobalEventHandlers { private HtmlCollection<IHtmlTableCellElement> _cells; public HorizontalAlignment Align { get { return this.GetOwnAttribute(AttributeNames.Align).ToEnum(HorizontalAlignment.Left); } set { this.SetOwnAttribute(AttributeNames.Align, value.ToString(), false); } } public VerticalAlignment VAlign { get { return this.GetOwnAttribute(AttributeNames.Valign).ToEnum(VerticalAlignment.Middle); } set { this.SetOwnAttribute(AttributeNames.Valign, value.ToString(), false); } } public string BgColor { get { return this.GetOwnAttribute(AttributeNames.BgColor); } set { this.SetOwnAttribute(AttributeNames.BgColor, value, false); } } public IHtmlCollection<IHtmlTableCellElement> Cells => _cells ?? (_cells = new HtmlCollection<IHtmlTableCellElement>(this, false, null)); public int Index { get { IHtmlTableElement ancestor = this.GetAncestor<IHtmlTableElement>(); if (ancestor == null) return -1; return ancestor.Rows.Index(this); } } public int IndexInSection { get { IHtmlTableSectionElement obj = base.ParentElement as IHtmlTableSectionElement; if (obj == null) return Index; return obj.Rows.Index(this); } } public HtmlTableRowElement(Document owner, string prefix = null) : base(owner, TagNames.Tr, prefix, NodeFlags.Special | NodeFlags.ImplicitelyClosed) { } public IHtmlTableCellElement InsertCellAt(int index = -1) { IHtmlCollection<IHtmlTableCellElement> cells = Cells; IHtmlTableCellElement htmlTableCellElement = base.Owner.CreateElement(TagNames.Td) as IHtmlTableCellElement; if (index >= 0 && index < cells.Length) InsertBefore(htmlTableCellElement, cells[index]); else AppendChild(htmlTableCellElement); return htmlTableCellElement; } public void RemoveCellAt(int index) { IHtmlCollection<IHtmlTableCellElement> cells = Cells; if (index < 0) index = cells.Length + index; if (index >= 0 && index < cells.Length) cells[index].Remove(); } } }