Keeping button controls in sync with MaintenanceFormToolStrip items


Author
Message
franka
franka
StrataFrame Beginner (28 reputation)StrataFrame Beginner (28 reputation)StrataFrame Beginner (28 reputation)StrataFrame Beginner (28 reputation)StrataFrame Beginner (28 reputation)StrataFrame Beginner (28 reputation)StrataFrame Beginner (28 reputation)StrataFrame Beginner (28 reputation)StrataFrame Beginner (28 reputation)
Group: Forum Members
Posts: 22, Visits: 35
I have a form that has New, Edit, Delete, Save and Undo buttons.  I want to keep those buttons in sync with the items on the MaintenceFormToolStrip.  I've tried the following code in both the ItemClicked event of the MaintenanceFormToolStrip and the EditingStateChanged event of the primary BO but they don't stay in sync.  Suggestions?  Thanks!!

Me.btnNew.Enabled = Me.MaintenanceFormToolStrip1.Items(0).Enabled

Me.btnEdit.Enabled = Me.MaintenanceFormToolStrip1.Items(3).Enabled

Me.btnDelete.Enabled = Me.MaintenanceFormToolStrip1.Items(4).Enabled

Me.btnSave.Enabled = Me.MaintenanceFormToolStrip1.Items(6).Enabled

Me.btnUndo.Enabled = Me.MaintenanceFormToolStrip1.Items(7).Enabled


StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
You would probably do best to handle the form's EditingStateChanged event which gets raised for each business object.  The problem with testing on the enabled state of the MaintenanceFormToolstrip is that it may not be set, yet... events get handled in whatever order the delegate feels like invoking them (two handlers on the same event are not guaranteed to fire in any specific order...).  So, your best bet is to look at the source code for the handler of the EditingStateChanged event within the MaintenanceFormToolstrip.  It cycles through the collections of business objects that are selected through the IncludeInForm*** properties and handles the events appropriately.  It might be easier to just copy that code over Smile
franka
franka
StrataFrame Beginner (28 reputation)StrataFrame Beginner (28 reputation)StrataFrame Beginner (28 reputation)StrataFrame Beginner (28 reputation)StrataFrame Beginner (28 reputation)StrataFrame Beginner (28 reputation)StrataFrame Beginner (28 reputation)StrataFrame Beginner (28 reputation)StrataFrame Beginner (28 reputation)
Group: Forum Members
Posts: 22, Visits: 35
I cloned the code from the MaintenanceToolStrip control and now the toolstrip buttons and the form's buttons stay in sync but I still have a problem with the right buttons being enabled/disabled.  Here's a copy of my form:

I have 2 BOs - Areas and Pods.  Areas is the parent and I have a relationship setup between the 2.  The primary BO for the form is Pods.  The lefthand listview is bound to Areas and is used just for navigation.  The righthand listview is for maintaining pods.  You'll notice that even though I navigated to a area with pods and a pod is actually selected, the Edit and Delete buttons don't get enabled.  If I click New and the Undo, the Save and Undo buttons get enabled.  But if I then navigate to another area with no pods the Edit and Delete buttons are still enabled.  I'm sure I've missed a property setting or something somewhere.  What should I check?

StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Hrm... in this scenario, you'll actually want to handle the processing on your own... otherwise, yes, your buttons are going to behave exactly like the buttons on the MaintenanceFormToolStrip.  So:

1) Handle the EditingStateChanged event to handle the Edit, New, Delete, Save and Undo buttons.

2) If the Pods business object IsDirty, then enable the Save and Undo, otherwise disable them.

3) If the EditingState of the Pods business object is Idle, then enable New, Edit, and Delete, otherwise, disable them.

That's pretty much what we do, except we test on all of the business objects on the form, not just one.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search