AngleSharp by AngleSharp

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

.NET API 1,261,568 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 ancestor.Rows.Index(this); return -1; } } public int IndexInSection { get { IHtmlTableSectionElement htmlTableSectionElement = base.ParentElement as IHtmlTableSectionElement; if (htmlTableSectionElement != null) return htmlTableSectionElement.Rows.Index(this); return Index; } } 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(); } } }