谁有WebBrowser修改网页表格的代码,分数200不够在加! 使用WebBrowser打开本机一个网页,希望修改其中一个选中的表格,修改表格的属性,包括列、行。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以使用DHTML操作阿。类似http://dotnet.aspx.cc/article/9d49b3ef-0f91-421b-841f-5d9a000bda04/read.aspx 例如The most complete C# Webbrowser wrapper controlhttp://www.codeproject.com/useritems/csEXWB.asphttp://msdn2.microsoft.com/zh-cn/library/system.windows.forms.htmldocument(VS.80).aspx 这二天太忙了,胡乱写了一个能够使用的插入行,插入列的代码,公开给大家参考参考了 //增加行 private void InsertRow() { if (this.tsAlterTable.Text.Trim() == string.Empty) { MessageBox.Show("请输入需要插入到第几行!"); this.tsAlterTable.Focus(); this.tsAlterTable.SelectAll(); return; } mshtml.IHTMLDocument2 doc2 = (mshtml.IHTMLDocument2)wbEdit.Document.DomDocument; IHTMLElement htmlSelObj = null; if (doc2.selection.type.ToUpper() == "CONTROL") { mshtml.IHTMLControlRange rangeObj = (mshtml.IHTMLControlRange)(doc2.selection.createRange()); if (rangeObj.length > 0) { htmlSelObj = rangeObj.item(0); if ((htmlSelObj != null)) { if (htmlSelObj.tagName.ToUpper() == "TABLE") { HTMLTable obj = (HTMLTable)htmlSelObj; int iRowLeagth = 0; if (this.tsAlterTable.Text.Trim() != string.Empty) { try { iRowLeagth = Convert.ToInt32(this.tsAlterTable.Text.Trim()); } catch { MessageBox.Show("请输入数字!"); } if (iRowLeagth > obj.rows.length) { MessageBox.Show("输入数字太大!"); return; } } int ColLen = obj.cells.length / obj.rows.length; HTMLTableRow row = (HTMLTableRow)obj.insertRow(iRowLeagth); for (int i = 0; i < ColLen; i++) { object elCell = row.insertCell(i); HTMLTableCell cell = (HTMLTableCell)elCell; cell.innerText = " "; } } } } } } C#中关于 listview控件的问题 C#关于字符串格式不正确问题 C++比较熟的大牛进来下,问个问题啊 为什么? 错误 CS0206: 属性或索引器不得作为 out 或 ref 参数传递 自定义控件的下拉框被下面的控件遮住了 怎么办? 面试题目,老大们帮忙 请问如何获得页面执行时间? 关于Visual Studio 2008 数据库 大家帮帮我,关于网站助手方面的问题 如何用正则表达式获取 聪明的.net程序员工具 CoolClass 1.2 将免费进行到底 无任何限制版 请问各位大虾在ASP.NET中在ASPX中写SVG怎么样调用session变量啊
类似
http://dotnet.aspx.cc/article/9d49b3ef-0f91-421b-841f-5d9a000bda04/read.aspx
http://www.codeproject.com/useritems/csEXWB.asp
http://msdn2.microsoft.com/zh-cn/library/system.windows.forms.htmldocument(VS.80).aspx
//增加行
private void InsertRow()
{
if (this.tsAlterTable.Text.Trim() == string.Empty)
{
MessageBox.Show("请输入需要插入到第几行!");
this.tsAlterTable.Focus();
this.tsAlterTable.SelectAll();
return; }
mshtml.IHTMLDocument2 doc2 = (mshtml.IHTMLDocument2)wbEdit.Document.DomDocument;
IHTMLElement htmlSelObj = null;
if (doc2.selection.type.ToUpper() == "CONTROL")
{
mshtml.IHTMLControlRange rangeObj = (mshtml.IHTMLControlRange)(doc2.selection.createRange());
if (rangeObj.length > 0)
{
htmlSelObj = rangeObj.item(0);
if ((htmlSelObj != null))
{
if (htmlSelObj.tagName.ToUpper() == "TABLE")
{ HTMLTable obj = (HTMLTable)htmlSelObj;
int iRowLeagth = 0;
if (this.tsAlterTable.Text.Trim() != string.Empty)
{
try
{
iRowLeagth = Convert.ToInt32(this.tsAlterTable.Text.Trim());
}
catch
{
MessageBox.Show("请输入数字!"); }
if (iRowLeagth > obj.rows.length)
{
MessageBox.Show("输入数字太大!");
return;
} } int ColLen = obj.cells.length / obj.rows.length;
HTMLTableRow row = (HTMLTableRow)obj.insertRow(iRowLeagth);
for (int i = 0; i < ColLen; i++)
{
object elCell = row.insertCell(i);
HTMLTableCell cell = (HTMLTableCell)elCell;
cell.innerText = " "; }
} }
}
}
}