110,528
社区成员
发帖
与我相关
我的任务
分享
private void testHtmlTable()
{
IHTMLTable table = htmlEditor1.HtmlDocument2.CreateElement("table") as IHTMLTable;
table.align = "center";
table.bgColor = "ghostwhite";
table.border = "2";
table.borderColor = "lightblue";
table.width = "100%";
table.height = "80%";
table.cellPadding = 4;
table.cellSpacing = 2;
IHTMLTableRow row = table.insertRow(-1) as IHTMLTableRow;
row.vAlign = "middle";
IHTMLTableCell cell = row.insertCell(-1) as IHTMLTableCell;
cell.align = "right";
cell.width = "40%";
(cell as IHTMLElement).innerText = "cell 1";
IHTMLTableRow row2 = table.insertRow(-1) as IHTMLTableRow;
row2.vAlign = "bottom";
IHTMLTableCell cell2 = row2.insertCell(-1) as IHTMLTableCell;
cell2.align = "left";
cell2.width = "60%";
//(cell2 as IHTMLElement).innerText = "cell 2";
IHTMLDOMNode cell2Node = cell2 as IHTMLDOMNode;
IHTMLDOMNode spanNode = cell2Node.childNodes.item(0) as IHTMLDOMNode;
(spanNode as IHTMLElement3).contentEditable = "false";
IHTMLTable2 table2 = table as IHTMLTable2;
IHTMLTableRow movedRow = table2.moveRow(0, 1) as IHTMLTableRow;
IHTMLTable3 table3 = table as IHTMLTable3;
table3.summary = "summary for table";
IHTMLDocument2 doc = this.htmlEditor1.HtmlDocument2;
IHTMLElement body = doc.GetBody();
IHTMLDOMNode rootNode = body as IHTMLDOMNode;
rootNode.appendChild(table as IHTMLDOMNode);
string html = (table as IHTMLElement).outerHTML;
MessageBox.Show(html);
}