Iterop Forms Toolkit 验证和焦点事件
我有一个现有的 VB6 应用程序,我正在慢慢地将其代码移动到 DotNet,在很多情况下,这意味着必须使用 DotNet 用户控件并使用 Interop Forms Toolkit v2 将它们托管在 VB6 表单中。
目前的方法是用C#开发用户控件,然后拥有一个继承C#版本的VB.NET用户控件,并以VB6形式承载VB.NET控件。
我唯一遇到困难的部分是当下一个获得焦点的控件位于 Dotnet 用户控件之外时,尝试捕获文本框中的 Leave 或 Validated 事件。这些事件根本不会触发,或者我的处理程序不会运行。
有人解决了这个问题还是我错过了什么?
I have an existing VB6 application which I am slowly moving its code to DotNet, in a lot of instances this means having to use DotNet usercontrols and hosting them in the VB6 form using the Interop Forms Toolkit v2.
At present the current method is to develop the usercontrol in C# and then have a VB.NET usercontrol which inherits from the C# version and host the VB.NET control in the VB6 form.
The only part where I am struggling is trying to capture the Leave or Validated events on a textbox when the next control to get focus is outside the Dotnet usercontrol. The events simply do not fire or my handlers do not get run.
Has anyone solved this issue or am I missing something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先要注意的是,您绝对不必将 VB.NET 与 Interop Forms Toolkit 一起使用,您可以直接使用 C# 代码。
查看这两篇 CodeProject 文章:
在第二篇文章中,有一个名为 ActiveXControlHelpers 的类,如果您查看其中您会看到如何连接您的 UserControl 以使事件顺利地从 VB 6.0 流向 .NET。例如,如果您通过 Tab 键切换到 VB 6.0 中的 .NET 控件,那么您希望通过 Tab 键切换该控件的所有组件,而不是切换到 VB 6.0 世界中的下一个控件。
我非常确定,如果您看看这是如何完成的,您应该能够在解决问题上取得一些进展。
First thing to note is that you definitely do not have to use VB.NET with the Interop Forms Toolkit, you can just use your C# code directly.
Check out these two CodeProject articles:
In the second article there is a Class called ActiveXControlHelpers, if you look in there you'll see how to wire-up your UserControl to have the events flow seemisly across VB 6.0 to .NET. For example tabing, if you tab onto the .NET control in VB 6.0 then you want to tab through all components of that control and not onto the next control in the VB 6.0 world.
I'm pretty sure that if you look how that is done, you should be able to make some headway with your problem.