简体   繁体   English

此 ActiveX 控件的 Click 事件无效

[英]The Click event is invalid for this ActiveX control

I use a proprietary IDE that is part of a large software package.我使用专有的 IDE,它是大型软件 package 的一部分。 At its core, however, C# is used as the language.然而,在其核心,C# 被用作语言。 Most.Net components and classes can be used.大多数.Net 组件和类都可以使用。 I can use it to create my own functions / WinForms, which are then integrated into an ERP system.我可以用它来创建我自己的函数/WinForms,然后将它们集成到 ERP 系统中。 This means that you can expand this system yourself.这意味着您可以自己扩展此系统。 This is quite well implemented but there is no documentation and the support is also poor at this point.这实现得很好,但没有文档,此时支持也很差。 That's why I'm trying my luck here.这就是我在这里碰运气的原因。 Maybe someone can help.也许有人可以帮忙。

I am currently programming a WinForms window that contains a WebBrowser control (wb).我目前正在编写一个包含 WebBrowser 控件 (wb) 的 WinForms window。 I'm pretty sure this is IE.我很确定这是 IE。 I can programmatically create and include HTML code via MemoryStream (ms):我可以通过 MemoryStream (ms) 以编程方式创建并包含 HTML 代码:

ms.Write(bytes, 0, bytes.Length);
wb.DocumentStream = ms;

It all works very well.这一切都很好。 Now I want to get events from the browser and have had the IDE create event handlers for this:现在我想从浏览器获取事件,并让 IDE 为此创建事件处理程序:

try {       
  wb.Click += new EventHandler(wb_Click);
  ...} etc.
public void wb_Click (object sender, EventArgs e)
  { }

The compiler shows no errors.编译器没有显示错误。 During the execution I get the error message: The Click event is invalid for this ActiveX control.在执行期间,我收到错误消息: Click 事件对此 ActiveX 控件无效。 What could trigger this error?什么可能触发此错误? W. Wolf W·沃尔夫

Thanks for your tips: I was able to solve this with the following code:感谢您的提示:我能够使用以下代码解决此问题:

...
HtmlElementCollection elements = wb.Document.GetElementsByTagName("span");
    for (int n = 0; n < elements.Count;n++)
    {
        elements[n].Click += new HtmlElementEventHandler(el_Click);
    }
...
public void el_Click (object sender, HtmlElementEventArgs e)
{
    HtmlElement el = (HtmlElement) sender;
    ShowInfo(el.Id);
}

I can continue to work with it.我可以继续使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM