On my form I have a UltraNumericEditor control. The control's value property is bound to a data table column (smallint) via Window.Forms.BindingSource.
The value contains some bitcoded status data, from which I initialize some checkboxes. If the control's visible property is set to false, the value property has no value (DBNull). Why? Is this a bug?
Regards
Markus
Hi Markus,
I have seen this happen for any control whose Handle is not yet created. The BindingManager in DotNet appears to ignore these controls. I assume the idea is that if the user cannot see the control, why bother wasting processing power on it.
In the past, I have gotten around this by forcing the creation of the handle for the control in question. You have to be very careful about this, though. Forcing the handle creation at the wrong time can cause some unexpected results which are very difficult to track down. So what I would do is expose a property or a method that gets the value from the control and inside this method, check the IsHandleCreated and if it's false, create the handle by calling CreateControl or Update on it, then return the Value.
Hello Dave,
I compared the Infragistics controls not the common toolbox controls. UltraTextEditor and UltraNumericEditor do not have the same behavior as I mentioned in my last post.
Hello Markus,
I believe this is expected behavior. If you'll try it with the System.Windows.Forms.TextBox control, you'll see that the control's Text property is never bound to the data if it is hidden at design time.
Hallo Dave,
I don't have a small sample project with all things around to reproduce. But I wonder why you can not reproduce this.
Just tell me that visible state should not have any influence. If so, I have to use a workaround (set visible = false after setup the checkboxes).
I just can tell you that the problem NOT happens if I use a UltraTextEditor instead UltraNumericEditor binding the same data field.
If I use the UltraNumericEditor with visible = false at design time no value is bound. If I change visible = true in code, the value is bound. If I change visible back to false on the next line of code, the value is still bound. It seems that it only not works if the editor is of type UltraNumericEditor and visible = false at design time.
Thank you for this information.
I tried this in the latest build of NetAdvantage 2011 Volume 2, but did not reproduce the issue. So that we're both on the same page, could you provide a sample project that reproduces the issue? You can attach a file to a post by selection the Options tab when editing your post.