Click here to Skip to main content
13,287,177 members (53,350 online)
Rate this:
Please Sign up or sign in to vote.
See more:

I want to know Which event fires when form lost it's focus? I am using Krypton Navigator.

I am using the following code to show a form.
private sub showForm(byval pform as form
Dim kryPage As New KryptonPage
With pform
.TopLevel = False
.Parent = kryPage
.Dock = DockStyle.Fill
End With
end sub

I am using the above code to show a form.

Reply Quote
Posted 4-Dec-12 20:16pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

This issue can really be confusing. Formally, the form has focus-related properties, but in a very different way than controls.

The "focus" always means keyboard focus, and it is something functional for focusable controls, not forms. A form is activated or deactivated, and when it is activated, the focus goes to the control which was focused before is any.

So, you can handle the events when each control is focused, or, you rather need to handle the event System.Windows.Forms.Form.Activated or System.Windows.Forms.Form.Deactiveate. Please see:[^],[^].

Espen Harlinn 5-Dec-12 18:11pm
Thank you, Espen.
kgmmurugesh 7-Dec-12 5:36am
I vb6, when we close a form it fires form_unload event, when we show a form it fires form_load, form_Activate event, when the user goes from form A to another form then he return to the form A, it fires form_activate event. I need the equivalent event in
Why are you asking about VB6 at all? I rather would reply "forget it"... Your question was about VB.NET, so consider accepting the answer formally (green button) -- thanks.
kgmmurugesh 8-Dec-12 4:43am
My actual requirement is to note the active control of a form when user go to another form without closing the current form.
Define "to note". Anyway, I answered your initial question, don't you see it?
Anyway, there is nothing to do. If you activate any form, its previously focused control gets focus.
kgmmurugesh 10-Dec-12 0:35am
No, Your answer is not working. If you need the coding to check i will send it.
No, I don't need it. My answer is working; are you kidding? -- the problem is too simple to unsure. You are doing something wrong, that's it.
kgmmurugesh 10-Dec-12 1:17am
No Sir, It is not working.
Sergey Alexandrovich Kryukov 10-Dec-12 16:34pm
It's your code is not working, not my advice.

OK, then you need to show some code sample. There are many ways to screw up things, and I don't know your way... :-)
The problem is really trivial. So, please create and test some code sample. Explain what you wanted to achieve by what means, what it was supposed to do, what did you observe in reality and why do you think it's wrong. I'll help you to fix it.
kgmmurugesh 11-Dec-12 3:10am
Use the following link to download my project & Krypton Tools.
Sergey Alexandrovich Kryukov 11-Dec-12 11:16am
No, thank you; this is too long way. Can you make a code sample focusing only on one problem?
kgmmurugesh 11-Dec-12 23:21pm
I want to write some code when the form lost it focus, while i am using krypton navigator.
Sergey Alexandrovich Kryukov 11-Dec-12 23:40pm
Is that is? Handle the event System.Windows.Forms.Form.Deactiveate.
Execute it under debugger to make sure your handler is really called.
If it is not, check up if the handler is really added to the invocation list of this event instance. Add code to the handler.

If you think it does not work, show these two fragments of your code. Or do you want me to show how to handle an event?
kgmmurugesh 11-Dec-12 23:42pm
I checked all the options, if i am not using krypton navigator it works well otherwise it doesn't work.
Sergey Alexandrovich Kryukov 11-Dec-12 23:48pm
You never mentioned that the problem is only with the use of Krypton navigator...
Are you handling the Deactivate event of the form, or something else? Are you sure you really deactivate the form? Are you sure your handler is really not called? using the debugger?

As this is a navigation-related component, it could intervene in the form operation, but... I still cannot imagine how this event could be disrupted... I think it should work as usual.
kgmmurugesh 11-Dec-12 23:56pm
Yes the problem is only with the use of krypton navigator.
Sergey Alexandrovich Kryukov 11-Dec-12 23:56pm
You see, your "does not work" is not informative. You need to tell what exactly happens. If you explicitly tell that your handler is not called under debugger, I would consider it as "not working" (so far, I hardly can believe in that)...
kgmmurugesh 11-Dec-12 23:59pm
Nothing happens, if you have any more doubts download and run my project.
You see, you are the one who is interested in resolution, not me. Therefore, will you please take a labor of running it under the debugger and checkup that the execution reaches required point? This is up to your, of course, but...
kgmmurugesh 12-Dec-12 0:08am
I already checked, the form_deactivate event not fires when i close or go to another form.
There is not such event "form_deactivate". You are not telling me that a handler is not called in a convincing way. You did not confirm that you checked it up under debugger (optionally: used system log), not any other way...
kgmmurugesh 13-Dec-12 1:10am
Private Sub Form2_Deactivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Deactivate

gAryFormControl(2) = Me.ActiveControl
Mdi.Text = Mdi.Text & "2 DE"
End Sub

is the above is form_deactivate event?
No, there is no such event; the event is System.Windows.Forms.Deactivate, and your method is an event handler; an event instance is the object of some class which supports the collection of handlers...

But this code fragment looks correct... and what, if you set a breakpoint at "gAryFormControl(2) = ..." the execution never stop at that line..? Would be strange...

kgmmurugesh 13-Dec-12 1:41am
i checked it many more times, it will not work when i am using krypton navigator, It works well when i am not using krypton navigator.
One questionable thing is the use of MDI... Are you deactivating an MDI child (I don't think you mentioned it before)? Can you try with regular windows (MDI is generally evil, best avoided...)?
kgmmurugesh 13-Dec-12 2:12am
Ok, Thanks. I must need MDI and Krypton Navigator.
Sergey Alexandrovich Kryukov 13-Dec-12 12:19pm
I can believe that you might need Krypton Navigator, but nobody really need MDI. This design style was proven so bad that Microsoft is doing hard work to phase it out. You don't want to scare off your user and give yourself development nightmare. Many user will deny working with software just because this is MDI. Alternatives (TabControl is the nearest) are way easier to develop and more convenient...
kgmmurugesh 14-Dec-12 0:08am
Ok, I will inform you after checking it without using mdi.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.171207.1 | Last Updated 5 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100