Winforms oddity: textbox not updating datasource

Posts   
 
    
JimFoye avatar
JimFoye
User
Posts: 656
Joined: 22-Jun-2004
# Posted on: 28-Jan-2006 03:00:08   

I have a form with several textboxes. They are all bound to fields in an entity. When I type something into the first textbox and tab off, SetNewFieldValue() does not get called in the entity. If I tab back and then tab out again, it gets called.

Also, this same control won't fire a validating event until I tab back into it and out again, which makes me think it is some peculiar winforms bug and has nothing to do with LLBLGenPro. I'm using the 1.1 framework.

Anybody know anything?

jeffreygg
User
Posts: 805
Joined: 26-Oct-2003
# Posted on: 28-Jan-2006 08:51:58   

Yea, highly doubtful it's LLBLGen Pro, but I would try databinding to a datatable as quick way to eliminate it as a factor. I've never had the exact problem you're having, but I've seen plenty of weirdness in WinForms databinding. I would also follow through with ensuring the LostFocus event gets fired and perhaps ending the current databinding session for the bound entity in that event as another thing to test.

Post your progress; I'm interested to see what the deal is. simple_smile

Jeff...

JimFoye avatar
JimFoye
User
Posts: 656
Joined: 22-Jun-2004
# Posted on: 28-Jan-2006 15:37:51   

The rest of the controls on the page work fine, it's just the first one. I deleted it and replaced it with a DevEx textbox, and set the tab order so it was now the first one, and had the same problem. Then I repeated the experiment with an Infragistics textbox and it worked OK. But I don't want to use Infragistics controls in this project.

This is quite vexing. I've found some blog posts about funkiness in winforms databinding and events, but nothing exactly like this.

I located this KB article:

http://support.microsoft.com/default.aspx?scid=kb;en-us;841096

and MS has sent me this hotfix, so I will install that and see if it makes a difference.

JimFoye avatar
JimFoye
User
Posts: 656
Joined: 22-Jun-2004
# Posted on: 28-Jan-2006 16:53:46   

Well the MS hotfix installation failed, heh.

I commented out the databinding, so LLBLGenPro and databinding are both out of the picture. When the form loads the Leave, Validating, and Validated events fire! I type something and then tab out of the control but nothing happens, it's as if the control is saying, "I fired those events already, you want me to fire them again??". Then I tab back and tab out, and now those events fire as expected.

It's the first control on the form, with tab index of 1, and the focus is thus automatically set there when the form loads.

I tell you, this is truly bizarre. Why would these events fire initially? And then not fire when I leave the control the first time? Usually the more stupid and outrageous the behavior, the more likely it is I've done something stupid. But I'm not doing anything else special that could mess things up, and as I said, I've even removed the databinding.

confused

jeffreygg
User
Posts: 805
Joined: 26-Oct-2003
# Posted on: 29-Jan-2006 02:43:15   

Can you recreate the problem in another (vanilla) project or form? Are you doing anything special in the form's Activate event? Does anything change if you use the mouse to leave the textbox as opposed to the tab key? Are you using visual inheritance?

If you want to get another pair of eyes on it, you can send me a portion of the project (my email's in my profile) and we can see if I can duplicate it. Obviously I've never had this particular problem, so I'm guessing its something specific to your setup.

Jeff...

JimFoye avatar
JimFoye
User
Posts: 656
Joined: 22-Jun-2004
# Posted on: 29-Jan-2006 19:24:11   

jeffreygg wrote:

Obviously I've never had this particular problem, so I'm guessing its something specific to your setup.

Ah, you are right about that! I figured out why the problem is happening, though it still appears to be a bug of some sort, either MS or perhaps it is a Devex bug.

I am opening two forms in my MDI container and then calling Activate() on the first. This is why all of the events fire for the control, because the focus is actually going to the second form when I create it. I can understand that, and it wasn't causing any problems for me.

But once the first MDI form is visible, when I tab out of that control, all of these events should still fire, and they don't until I return to the control and tab out again. That sure seems like a bug.

Now that I know what is "causing" the problem I can "fix" it.

Thanks for your offer to help!

simple_smile

jeffreygg
User
Posts: 805
Joined: 26-Oct-2003
# Posted on: 30-Jan-2006 21:45:42   

Good luck to you, and let me know how/if I can help. simple_smile

Jeff...