HtmlElement he = IE.Document.GetElementById("username"); he.SetAttribute("value", textBox1.text);
哥们 你这是把textbox1多行的内容全部获取
StringBuilder stringToRead = new StringBuilder(); stringToRead.AppendLine("Characters in 1st line to read"); stringToRead.AppendLine("and 2nd line"); stringToRead.AppendLine("and the end"); List<string> strList=new List<string>(); using (StringReader reader = new StringReader(stringToRead.ToString())) { while(reader.peek>-1){ strList.add(reader.ReadLine);
he.SetAttribute("value", textBox1.text);
哥们 你这是把textbox1多行的内容全部获取
StringBuilder stringToRead = new StringBuilder();
stringToRead.AppendLine("Characters in 1st line to read");
stringToRead.AppendLine("and 2nd line");
stringToRead.AppendLine("and the end");
List<string> strList=new List<string>();
using (StringReader reader = new StringReader(stringToRead.ToString()))
{
while(reader.peek>-1){
strList.add(reader.ReadLine);
}
}
这样把没行都放在了strList里面 你要读取第一行就是strList[0] 第二行就是strList[1]...具体请参考MSDN 详细资料
http://msdn.microsoft.com/zh-cn/library/system.io.stringreader.aspx
哥们 你这是把textbox1多行的内容全部获取
你要获取一行啊?把\r\n分割出来就好啦
获取第一行内容代码是这样的:
webBrowser1.Document.GetElementById("username").InnerText = textBox1.Text;
webBrowser1.Document.GetElementById("password").InnerText = textBox2.Text;
下一行代码写不出来
把textBox1和textBox2的Multiline属性改为true。
获取第一行内容代码是这样的:
webBrowser1.Document.GetElementById("username").InnerText = textBox1.Lines[0];
webBrowser1.Document.GetElementById("password").InnerText = textBox2.Lines[0];
获取第二行内容代码是这样的:
webBrowser1.Document.GetElementById("username").InnerText = textBox1.Lines[1];
webBrowser1.Document.GetElementById("password").InnerText = textBox2.Lines[1];
webBrowser1.Document.GetElementById("username").InnerText = textBox1.Lines[IndexNum];
webBrowser1.Document.GetElementById("password").InnerText = textBox2.Lines[IndexNum];
...
IndexNum++;
webBrowser1.Document.GetElementById("password").InnerText = textBox2.Text;
定义一个全局int IndexNum=0; 在buttonclick事件里
webBrowser1.Document.GetElementById("username").InnerText = textBox1.Lines[IndexNum];
webBrowser1.Document.GetElementById("password").InnerText = textBox2.Lines[IndexNum];