views:

91

answers:

1

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?

+2  A: 

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.

ParmesanCodice