Textbox LostFocus and Gotfocus

Hi,

The Textbox LostFocus and GotFocus events fires every time the form loads.I need these events to be fired only when i touch the textbox.I am using netcf 1.0.how to solve this



Answer this question

Textbox LostFocus and Gotfocus

  • SaloS

    Ok, defenitly I missed someting.....

    There are focus events, conveniently placed under the focus group.

    I missed them in Alphabetical order, since they are called enter and leave.

    I'm used to got and lost focus name for this event.

    Anyway forget it, I'm still a little new on C#, but it is very good so far!



  • Stephanie L

    I got some other problem with the focus in visual studio 2005 .NET.

    There is no got or lost focus event in C# Visual Studio 2005 .NET (at least not for textboxes, I haven't looked but I expect the same for other controls)

    I need these events to be there! (at least I do today for this project)

    Now I'm pretty sure I can find another way of solving my problem, but I still think each control should have a lost and got focus event by default.

    In this project I need lost and got focus events for most of my controls; I would hate to make my own component set, inherited from the original components, with as only addition a lost and got focus event for each control.

    But I will if I have to....

    Am I missing someting here or are the no events for focus change in C# And if not why

    Personally I think if there are no focus events for the controls Microsoft should release an update so each control has these events. It would make thinks easier I think.

    Kindest regards,

    Uncle X



  • Andreas Fabri

    Put a breakpoint in LostFocus handler and check the stack. I think it;s a side effect of something else you are doing

  • Andrew Buyan

    I could be wrong but I believe naturally this will be fired as it will lose focus since it will be drawing the next control in line and will get focus when the control is to be drawn, causing the gotfocus event to be fired.

    I guess *maybe* you could arrange the code so that the events are created AFTER the form controls have been drawn/put in place in the designer view code.

    What this would do is that once all the controls and so on have been placed on the form, the next step would be to subscribe/create events which means that the events will not be fired when drawing the controls on the form, but after when your application is running.

    hope this gives you some guidence



  • Textbox LostFocus and Gotfocus