下面是下拉列表的的HTML代码,现在默认的选择是“苹果”,要用webBrowse模拟选择“橘子”(即更改原来默认的选择)代码该如何写?请指教,先谢谢了。<TR>
<TD class=colorred align=right>水果</TD>
<TD align=left colSpan=3><SELECT id=fruit
<OPTION value=8 selected>苹果</OPTION> <OPTION
value=7>橘子</OPTION> <OPTION value=4>香蕉</OPTION></SELECT>
</SELECT></TD></TR>
<TR>
<TD class=colorred align=right>水果</TD>
<TD align=left colSpan=3><SELECT id=fruit
<OPTION value=8 selected>苹果</OPTION> <OPTION
value=7>橘子</OPTION> <OPTION value=4>香蕉</OPTION></SELECT>
</SELECT></TD></TR>
<TR>
解决方案 »
- Mapx 自定义selectionTool,问题提问!
- 【新手】写代码时弹出的小图标代表什么意思?
- Winform:添加报警声音
- dsoframer嵌套子窗体操作打开Excel出现锁定的问题
- 错误讯息 - 系统呼叫的资料区太小
- ComboBox控件是动态绑定值的,现在从数据库中获得读取一值,该值将在控件中显示出来。有什么方法吗?
- VS2003在创建项目的时候老是提示错误
- 哪儿有象vs 2005 解决方案资源管理器这种TreeView控件下载(或是如何实现)?
- 求助 C# 正则表达式
- 如何在ComboBox中显示树型结构?
- 如何获取Xml文档一个时间段内的节点
- 修改msg文件的发件人和发件时间。。。。版主帮帮忙~~~~~
{
if (webBrowser1.Document != null)
{
HtmlDocument doc = webBrowser1.Document;
HtmlElementCollection elems = doc.All.GetElementsByName(tableName);
if (elems != null && elems.Count > 0)
{
HtmlElement elem = elems[0]; // Prepare the arguments.
Object[] args = new Object[2];
args[0] = (Object)"-1";
args[1] = (Object)"0"; elem.InvokeMember("moveRow", args);
}
}
}
if (webBrowser1.Document.All[i].GetAttribute("value") == "")
{
s= webBrowser1.Document.All[i];
s.SetAttribute("checked", "checked");
}mshtml.dll
using mshtml
mshtml.IHTMLSelectElement select =(mshtml.IHTMLSelectElement)
webBrowser1.Document.GetElementById("").DomElement;
select.selectedIndex =3;
该属性设置选项的当前状态,如果为 true,则该选项被选中。该属性的初始值来自 <option> 的 selected 属性。》应该是改变option的selected属性,谁知道怎么改啊?
HtmlElement s= null;
if (webBrowser1.Document.All[i].GetAttribute("value") == "")
{
s= webBrowser1.Document.All[i];
s.SetAttribute("checked", "checked");
}
IHTMLSelectElement select = (IHTMLSelectElement)doc.GetElementById("fruit").DomElement;
select.selectedIndex = 1;
我是这样写的,但总是报错,说是“未将对象引用设置到对象的实例”,这是什么原因造成的啊