tags:

views:

314

answers:

3

This is a .net problem with winforms, not asp.net.

I have a windows form with several tabs. I set data bindings of all controls when the form is loaded. But I have noticed that the data bindings of controls on the second tab do not work. Those bindings work only when the form is loaded and when I select the second tab. This brings the suspicion to me: data bindings work only when bound controls become visible.

Anyone can tell me whether this is true or not? It is not hard to test this but I would like to know some confirmation.

Thanks

+1  A: 

You are correct. A data-bound control are not updated until the control is made visible.

The only reference I can find for this at the moment is this MSDN thread.

Michael Petrotta
Wow. I guess I've just always gone for the data via the datasource - I really had no idea the bindings were only really working when the control was visible.
overslacked
A: 

This is not something I've come across directly. However, you might be experiencing a problem with the BindingContext. Without more details it's hard to say, but if I were you I'd set a breakpoint and make sure the controls are all bound in the same context.

overslacked
A: 

For autosized controls, overriding the GetPreferredSize method return a width & height of -1 will make the control look invisible but still participate in the binding.

hjb417