Groups | Blog | Home
all groups > dotnet windows forms databinding > september 2005 >

dotnet windows forms databinding : Checkbox databinding issue on descendant control


Lynn
9/15/2005 9:47:09 AM
Hi, I have a checkbox that I have added to a descendant user control. I am
binding the checkbox to the dataset on the ancestor control. Any changes
made to the checkbox is not being picked up in my update. No error is
thrown. I ran through the debugger and compared the difference between the
binding of the checkbox on the descendant and a checkbox I have on the
ancestor. I have pasted the BindingManagerBase property for the two
checkboxes for your review. I retrieved this information running the
solution in Debug mode. From comparing the two property listing, the
descendant checkbox binding doesn't pickup the DataRowView and gets an
IndexOutOfRangeException error. However this error was not thrown during
execution. I only found it while checking for the BindingManagerBase
Property in the Debugging immediate window.

BindingManagerBase Property for descendant checkbox:
{System.Windows.Forms.RelatedCurrencyManager}
[System.Windows.Forms.RelatedCurrencyManager]:
{System.Windows.Forms.RelatedCurrencyManager}
System.Object: {System.Windows.Forms.RelatedCurrencyManager}
Bindings: {System.Windows.Forms.ListManagerBindingsCollection}
bindings: {System.Windows.Forms.ListManagerBindingsCollection}
BindType: {"System.Data.DataView"}
Count: 0
Current: <error: an exception of type: {System.IndexOutOfRangeException}
occurred>
DataSource: {System.Data.DataView}
IsBinding: false
onCurrentChangedHandler: <undefined value>
onPositionChangedHandler: <undefined value>
Position: -1
pullingData: false

BindingManagerBase Property for ancestor checkbox:
{System.Windows.Forms.RelatedCurrencyManager}
[System.Windows.Forms.RelatedCurrencyManager]:
{System.Windows.Forms.RelatedCurrencyManager}
System.Object: {System.Windows.Forms.RelatedCurrencyManager}
Bindings: {System.Windows.Forms.ListManagerBindingsCollection}
bindings: {System.Windows.Forms.ListManagerBindingsCollection}
BindType: {"System.Data.DataView"}
Count: 1
Current: {System.Data.DataRowView}
DataSource: {System.Data.DataView}
IsBinding: true
onCurrentChangedHandler: <undefined value>
onPositionChangedHandler: <undefined value>
Position: 0
pullingData: false

Lynn
9/15/2005 1:01:09 PM
I discovered that the problem is also occurring for textboxes which I've
added to the descendant control. It seems that the bindings on the textbox
and checkbox are not being recognized.

[quoted text, click to view]
v-jetan NO[at]SPAM online.microsoft.com (
9/16/2005 12:00:00 AM
Hi lynn,

Thanks for your post.

From the information you provided, it is hard for us to understand it
completely. It is possible for you to narrow down the problem into a little
sample project and attach it in the further reply, then I think we can
understand it much better and do some troubleshooting for you.

Currently, I will provide some suggestion for you. First, I think you can
turn on the first chance exception handling in your VS.net debugger. Then
when the IndexOutOfRangeException is thrown out, it will break in the
VS.net IDE as a breakpoint.(Normally, this exception is catched by the .Net
Winform code in second chance exception, and VS.net debugger will not break
in )

Also, you have to setup the correct symbol for .Net debugging, then when
VS.net debugger catched this first chance exception, we can view the
correct call stack for this exception. Call stack information is very
important for debugging this issue. And you can see what wrong with it.

I will wait for your further feedback. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Lynn
9/16/2005 4:27:05 PM
Hi Jeffrey,

I don't think it is easily possible for me to send you a snippet of the
code. Our architecture is quite complicated and interwined involving not
only the forms and user controls but interactions with multiple business
classes and datasets.

I think part of the issue may be due to how we are handling our datasets on
each of the user controls. What I have discovered is that the combo boxes on
the descendant controls are working perfectly fine. I suspect the binding is
holding up for the combo boxes because I am populating them and assigning the
datasource on the descendant. I have a work around for my problem and that
is to place all the controls on the ancestor and hide the ones that are not
in common with all of its descendants. I just have to make the controls
visible on the descendants that need them. That seems to be defeating the
whole purpose of inheritance but at this point I don't have a better
solution.

Lynn



[quoted text, click to view]
v-jetan NO[at]SPAM online.microsoft.com (
9/19/2005 6:06:13 AM
Hi Lynn,

Thanks for your feedback.

Yes, I see your concern. Product projects are not easy to narrow down. Have
you tried my original suggestion to turn on First chance exception handling
in VS.net IDE? With this, you should can break into the VS.net IDE for
IndexOutOfRangeException.(To turn on this, you can press ctrl+alt+E in
VS.net IDE, then select "Common Language Runtime Exceptions" node, in below
"When the exception is thrown" groupbox, select "break into the debugger"
option)

Additionally, can you clarify what does descendant/ancestor controls mean?
Do they have inheritance relation or parent/child relation? Also, what does
"the dataset on the ancestor control" mean? DataSet should be just an
ADO.net object, it should does not belong to any control, we can bind many
controls to the same DataSet without any problem, once the datasource and
datamember are the same, the databinding between these controls will be
synchronized.

Hope you can provide some more information about this issue.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Lynn
9/19/2005 7:00:09 AM
Hey Jeff,

Sorry about the unclear explanation. Let me try to clarify my architecture
design. I've built a base user control, which contains textboxes,
comboboxes, checkboxes, etc.). Here is the base code:"public class
TGeneralInformationBaseUC : System.Windows.Forms.UserControl". I then extend
the base control. Here is the code for the derived user control: "public
class SMGeneralInformationUC :
NAMISM.WinUI.TemplateUI.TGeneralInformationBaseUC". We build our
sqlDataAdapter, SqlConnection, and Dataset in a separate class (a.k.a
business class). All database interactions are performed by calling this
"business class". On my base control I've instanced the business class so I
can make use of the dataset to setup my binding for the textboxes,
checkboxes, etc. on my base control. I've made all my controls on the base
protected so they are visible on my derived control. My issue is when I add
a control, for example a checkbox, to the derived
control, and bind it to the dataset on the base control, binding does not
work. Hopefully, this helps to clarify my problem.




[quoted text, click to view]
v-jetan NO[at]SPAM online.microsoft.com (
9/26/2005 7:13:42 AM
Hi Lynn,

Have you referred my sample project? If you have any further concern,
please feel free to feedback. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
AddThis Social Bookmark Button