We are converting a Visual Basic 6.0 application to vb.net 2008 and are having an issue, while executing the code under “form activated event”. There is a difference in behavior between form.activate in Visual Basic 6.0 and form.activated in vb.net. In Visual Basic 6.0, the Activate event was raised only when switching between forms in the application; in Visual Basic .NET, the Activated event also is raised in case of showing messagebox and when switching from other applications.(by msdn)

In vb6 application the purpose to use form activate event is, to execute some code when forms become active. In our application forms are loaded, hide and show in different flows. So whenever this form is shown from hide state or any of its child form return focus to it, we need to reflect different changes in the application to the specific form controls.

* For example user changes its application preferred language.
* As the application is huge, so shifting logic to other place with respect to the current scenario might solve the problem for the current form but then I have to re think it for all other forms (which is very hectic and more or less not feasible).

In the migration process it is required to make as little changes in the existing code execution hierarchy. So we need a similar behavior like form.activate in vb6.0 with some other event or restrict some functionality of Activated event in vb.net.

hmm i thought maybe you could have a flag set to true when another form gets focused then when the form(in question) is activated you do the work only if the flag is set to true then you reset it to false !
i think that way when the form gets focus and finds that flag = false then it knows that nothing happened while it was unfocused.
give it a try .. maybe it'll work ..

Thanks for your reply, the solution you provide will solve the problem partially, as our project is very huge more than 100 forms. This solution looks correct but is infeasible in our case, to use flag at that large level. I need a more generic kind of solution i.e. to override a event definition or behavior for all my project. I don't know how this can be achieved, but on the other hand i find different .net winform UI components which provide such altered/modified behavior in windows form events. So i know this is possible but don't know the solution. Please share any kind of "event behavior" altering material.

Thanks for your help any way

This article has been dead for over six months. Start a new discussion instead.