c# - Adding element to Webbrowser -
i have table id="table1" loaded in webbrowser webbsppagina. need add together row. code can add together row table element isnt shown on webbrowser. need alter webbrowser?
htmlelement element = webbsppagina.document.getelementbyid("table1"); htmlelement mtbody = element.firstchild; htmlelement mtr = webbsppagina.document.createelement("tr"); htmlelement mtd1 = webbsppagina.document.createelement("td"); htmlelement mtd2 = webbsppagina.document.createelement("td"); htmlelement mtd3 = webbsppagina.document.createelement("td"); mtd1.style = "vertical-align: top"; mtd2.style = "vertical-align: top"; mtd3.style = "vertical-align: top"; mtd1.setattribute("class", "ms-rtetablecells"); mtd2.setattribute("class", "ms-rtetablecells"); mtd3.setattribute("class", "ms-rtetablecells"); mtd1.innertext = "teamviewer id"; mtd2.setattribute("id", "teamviewerid"); mtd3.setattribute("id", "teamvieweridextra"); mtr.appendchild(mtd1); mtr.appendchild(mtd2); mtr.appendchild(mtd3); mtbody.appendchild(mtr);
i tried code, working me if in next way
//add table in form load event private void form1_load(object sender, eventargs e) { webbsppagina.documenttext = "<table id='table1'><tr><td>hello</td></tr></table>"; } //added code in button click event private void button1_click(object sender, eventargs e) { htmlelement element = webbsppagina.document.getelementbyid("table1"); htmlelement mtbody = element.firstchild; htmlelement mtr = webbsppagina.document.createelement("tr"); htmlelement mtd1 = webbsppagina.document.createelement("td"); htmlelement mtd2 = webbsppagina.document.createelement("td"); htmlelement mtd3 = webbsppagina.document.createelement("td"); mtd1.style = "vertical-align: top"; mtd2.style = "vertical-align: top"; mtd3.style = "vertical-align: top"; mtd1.setattribute("class", "ms-rtetablecells"); mtd2.setattribute("class", "ms-rtetablecells"); mtd3.setattribute("class", "ms-rtetablecells"); mtd1.innertext = "teamviewer id"; mtd2.setattribute("id", "teamviewerid"); mtd3.setattribute("id", "teamvieweridextra"); mtr.appendchild(mtd1); mtr.appendchild(mtd2); mtr.appendchild(mtd3); mtbody.appendchild(mtr); }
c# .net webbrowser-control
No comments:
Post a Comment