首页 > 解决方案 > 如何拆分列表框中的第一行并将其复制到c#中的webbrowser1 elemnt

问题描述

c#拆分listbox1中的第一行并复制“|”之前的行 然后将其粘贴到 webbrowser1 元素和第二个,第三个

listbox1 中的元素如下所示:1111111|88|8888|888|

第一步复制 1111111 然后将其传递到 getElemtby id 将其传递到此 id 输入

第二步复制第二个 88,如果它是相等的,把它按 id 放在 webbrowser1 元素中,比如月 01 到 12

webBrowser1.Document.GetElementById("month").SetAttribute("selectedIndex", "1");

第三步复制第三个 8888,如果相等,将其按 id 放入 webbrowser1 元素中,如 2018 年至 2029 年

如果它喜欢 2018 年

webBrowser1.Document.GetElementById("year").SetAttribute("selectedIndex", "1");

第三步将四个888复制并粘贴到webbrowser1中的id中

逐行执行这些步骤,直到长度 listbox1 结束

然后单击元素我在下面尝试了这个

workwebBrowser1.Document.GetElementById("ys_primary").InvokeMember("click");

然后检查 webbrowser1 中的下一页是否像复制任何项目 ID 一样处理它

标签: c#winformssplit

解决方案


    // here is the solution 
        string str = listBox1.Items[0].ToString();

        char[] b = new char[str.Length];

   using (StringReader sr = new StringReader(str))
        {
            // Read 16 characters from the string into the array.
            sr.Read(b, 0, 16);

    //  to show the result print
            string output = string.Join("", b);
            MessageBox.Show(output);

    //  but what if i want to read from 5 to 9
    // it does not resolve yet!

推荐阅读