problem updating CurrencyManager.Position when binding to a custom object's ArrayList property

B

Bob DeRemer

I have a WinForm app that contains a custom Treeview and a two Panel
container controls. Selecting the tree root node displays Panel 1,
selecting any child nodes of the root displays panel 2. Both panels contain
text boxes.

The custom treeview control has a DataSource property - so I can bind my
custom object's ArrayList property. The ArrayList property, called Tests,
is simply a collection of Test objects. When I initialize the application,
and load up my custom object [w/ it's arraylist of test objects], I do the
following:

1) clear all databindings on the textboxes in the panels
2) set the CustomTreeView.DataSource property - which causes the TreeView to
be built
3) add all databindings on the textboxes in the panels

Upon initial startup and loading, my databinding appears to be working
great. I can navigate the tree nodes and the testboxes are updated in
accordingly. I do the updating in the CustomTreeView's OnAfterSelect
override - where I set the CurrencyManager.Position property to the
appropriate List item it is managing.

My problem starts when I decide I want to add a new Test object to my custom
objects ArrayList of tests. I'm having a problem updating the Position
property of the CurrencyManager on my custom TreeView. After updating the
ArrayList, I can see that the CurrencyManager's list count is incremented by
one. I can even see the new object - which is correct. But, when I select
the new node in the tree, and attempt to assign it's position index to the
CurrencyManager.Position [in the OnAfterSelect method], it doesn't do
anything. I can see that the CM's count is one larger than the value I am
trying to set, but it's as if there's an internal counter that ignores my
new value. The Position stays at whatever it is currently.

I have tried getting the CM and doing a refresh, calling
SuspendBinding/REsumeBinding, setting the Datasource property to null/then
back - all to no avail. I hope this is operator error, but I cannot seem to
find anything that works.

Thanks in advance for any suggestions,
Bob
 
J

Jeffrey Tan[MSFT]

Hi Bob,

Based on my understanding, you implemented a DataSource property for your
customized treeview, then populate the textboxes in panel control with
simple databinding which meets problem when adding new items.

Can you show us some code snippet or a simple reproduce project to
reproduce your problem? Then we can help you better.

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.
 
J

Jeffrey Tan[MSFT]

Hi Bob,

Thanks very much for your reply!

I have received your attachment code file, but it only contains the
TestTreeView. But without the code or project of how you use this
TestTreeView to reproduce the problem.

Without the code snippet of how you manipulate the databinding with
TestTreeView, I can not reproduce out your problem and can not help you
better.

I hope you may create a sample project with both TestTreeView and the code
how to manipulate it to reproduce the problem, then I will help you out.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

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.
 
B

Bob DeRemer

Jeffrey,

Hi. Due to a deadline, I must move forward with the non-databound approach.
So far, this hasn't been too bad - given my UI requirements. I thank you
for your help. After I get deliver this initial drop, I'll see if I can get
the original solution zipped up and sent to you.

Thanks,
Bob
 
J

Jeffrey Tan[MSFT]

Hi Bob,

Thanks very much for your reply!

Ok, no problem, if you have time, please feel free to post and help us to
reproduce this problem, we will help you. 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top