/// <summary>Gets the first child element with the given tag.</summary> /// <param name="tag">The html tag to look for.</param> /// <returns>The first child with the tag.</returns> public Element getElementByTagName(string tag) { List <Element> results = html.getElementsByTagName(tag, true); if (results.Count > 0) { return(results[0]); } return(null); }
public override void WidthChanged() { if (ColumnWidths == null) { // No rows. return; } // First, how many columns have no set width, and how much space is left for them? // That's the amount of nulls in the ColumnWidths list. int noWidth = 0; int spaceLeft = Element.Style.Computed.InnerWidth; for (int i = 0; i < ColumnWidths.Count; i++) { ComputedStyle column = ColumnWidths[i]; if (column == null) { noWidth++; } else { spaceLeft -= column.PixelWidth; } } if (spaceLeft > 0 && noWidth > 0) { // Spread it evenly: NoWidthPixels = spaceLeft / noWidth; } else { NoWidthPixels = 0; } // Make sure all td's have the width of the max. // This is required as not all child tds will have WidthChanged called directly. List <Element> allCells = Element.getElementsByTagName("td"); foreach (Element element in allCells) { TdTag tag = (TdTag)(element.Handler); tag.WidthChanged(); } // Same for th too // This is required as not all child ths will have WidthChanged called directly. allCells = Element.getElementsByTagName("th"); foreach (Element element in allCells) { ThTag tag = (ThTag)(element.Handler); tag.WidthChanged(); } }