100分 新手求解决~~~~在线等~~~

dfsdf000 2013-11-20 09:45:11
C# winform中 有控件 webbrowser1 textbox1 textbox2 button1 button2

其中webbrowser1的控件id为 【username password】 以url=http://www.0596lh.com为例

如何实现:

1.首先,把多行内容复制粘贴到textbox1和textbox2中

2.点击button1则 把textbox1的第一行内容输入到webbrowser1中控件id为username的文本框中
把textbox2的第一行内容输入到webbrowser1中控件id为password的文本框中

3.点击button2则 把textbox1的第下一行内容输入到webbrowser1中控件id为username的文本框中
把textbox2的第下一行内容输入到webbrowser1中控件id为password的文本框中
...全文
258 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
失落的神庙 2013-11-20
  • 打赏
  • 举报
回复
定义一个全局int IndexNum=0; 在buttonclick事件里 webBrowser1.Document.GetElementById("username").InnerText = textBox1.Lines[IndexNum]; webBrowser1.Document.GetElementById("password").InnerText = textBox2.Lines[IndexNum]; ... IndexNum++;
feiniao19830822 2013-11-20
  • 打赏
  • 举报
回复
引用 4 楼 u012876111 的回复:
[quote=引用 3 楼 u011223070 的回复:] 想办法把第一行的内容取出来,其他的就好办了
获取第一行内容代码是这样的: webBrowser1.Document.GetElementById("username").InnerText = textBox1.Text; webBrowser1.Document.GetElementById("password").InnerText = textBox2.Text; 下一行代码写不出来 [/quote] 把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];
u011781558 2013-11-20
  • 打赏
  • 举报
回复
TextBox1.Text.Split(new char[]{'\n'})[0]。 这样写懂不?根据下标取就行了。
zhou23141622 2013-11-20
  • 打赏
  • 举报
回复
引用 11 楼 u012876111 的回复:
[quote=引用 10 楼 zhou23141622 的回复:] HtmlElement he = IE.Document.GetElementById("username"); he.SetAttribute("value", textBox1.text);
哥们 你这是把textbox1多行的内容全部获取 [/quote] 你要获取一行啊?把\r\n分割出来就好啦
Teln_小凯 2013-11-20
  • 打赏
  • 举报
回复
感觉你这个有点像是文件导入功能.....帐号密码批量导入的样子,还是有点暴力破解的意思...
Teln_小凯 2013-11-20
  • 打赏
  • 举报
回复

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
dfsdf000 2013-11-20
  • 打赏
  • 举报
回复
引用 10 楼 zhou23141622 的回复:
HtmlElement he = IE.Document.GetElementById("username"); he.SetAttribute("value", textBox1.text);
哥们 你这是把textbox1多行的内容全部获取
zhou23141622 2013-11-20
  • 打赏
  • 举报
回复
HtmlElement he = IE.Document.GetElementById("username"); he.SetAttribute("value", textBox1.text);
yusheng622 2013-11-20
  • 打赏
  • 举报
回复
哥几个,我也是来学习的
dfsdf000 2013-11-20
  • 打赏
  • 举报
回复
楼上的哥几个 代码来 ~~~ 我还是小白呢~~~
Teln_小凯 2013-11-20
  • 打赏
  • 举报
回复
http://msdn.microsoft.com/zh-cn/library/system.io.textreader.aspx 可以把文字转成流之后,把每行的文本放在 一个List<string> 集合里面 ,然后自己去计算读取的下标 就好了
Teln_小凯 2013-11-20
  • 打赏
  • 举报
回复
你不如试试文本读取,把所有内容放在一个txt里面,然后用流读取的时候可以一行一行读取,或者把文本直接转成流,然后在一行一行读取
云飞兄 2013-11-20
  • 打赏
  • 举报
回复
你去看一下 winform与html 通过webBrowser的交互,然后就明白怎么做了
dfsdf000 2013-11-20
  • 打赏
  • 举报
回复
引用 3 楼 u011223070 的回复:
想办法把第一行的内容取出来,其他的就好办了
获取第一行内容代码是这样的: webBrowser1.Document.GetElementById("username").InnerText = textBox1.Text; webBrowser1.Document.GetElementById("password").InnerText = textBox2.Text; 下一行代码写不出来
wyufen 2013-11-20
  • 打赏
  • 举报
回复
想办法把第一行的内容取出来,其他的就好办了
dfsdf000 2013-11-20
  • 打赏
  • 举报
回复
嗯 确定~~~
稻庄 2013-11-20
  • 打赏
  • 举报
回复
你确定你会结贴麽
啥技术也不懂 2013-11-20
  • 打赏
  • 举报
回复
webBrowser1.Document.GetElementById("username").InnerText = textBox1.Text; 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];

110,545

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧