本文介绍了删除的HtmlElement对象编程方式使用C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

web浏览器控制,如何删除的HtmlElement 的对象?有在的HtmlElement 没有方法类来做到这一点。作为一种变通方法,我可以创建一个虚拟的HtmlElement (不将其插入的HTMLDocument ),到了我然后插入(通过的appendChild )的的HtmlElement 对象被删除。这感觉就像一个黑客。有没有更好的方式来做到这一点?

In a WebBrowser control, how do I remove HtmlElement objects? There are no methods in the HtmlElement class to accomplish this. As a workaround, I can create a "dummy" HtmlElement (without inserting it into the HtmlDocument), into which I then insert (via AppendChild) the HtmlElement objects to be removed. This feels like a hack. Is there a better way to do this?

P.S。我想保留的HtmlElement 在内存中供以后使用,不能简单地破坏它(这是什么设置其父的innerHTML 为空字符串会做)

P.S. I want to retain the HtmlElement in memory to be used later, not simply destroy it (which is what setting its parent's innerHtml to an empty string would do)

推荐答案

看这个WebControl的传承,具有特色的负载:的

Look at this WebControl Heritance, with loads of feature: http://www.codeproject.com/KB/miscctrl/csEXWB.aspx

您可以通过ID添加一个remove方法来删除元素。

You could add a remove method to del element by id.

希望这有助于

这篇关于删除的HtmlElement对象编程方式使用C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 06:11