StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



Maintenance Form Toolstrip not saving button...Expand / Collapse
Author
Message
Posted 06/21/2006 3:32:05 PM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: Forum Members
Last Login: 02/28/2007 12:59:00 PM
Posts: 15, Visits: 42
Guys,

I am trying to add some additional buttons and move the buttons around on the maintenance form toolstrip control.

It appears to save, but after I run the winforms app they are all put back to default positions.

Any ideas?

Jason

Post #1621
Posted 06/21/2006 4:44:04 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Yesterday @ 10:38:53 PM
Posts: 2,683, Visits: 1,883
The problem comes from the MaintenanceFormToolstrip being a control that has it's own InitializeComponent method... when the designer changes the order of the buttons on the toolstrip, it only changes them on the instance of the toolstrip that is in the designer, but it cannot change them when the form runs.  So, you will most likely need to create a method to swap the order of the buttons programmatically when the form instantiates or loads.  Or, you can subclass the MaintenanceFormToolstrip to create your own and put the logic to swap the buttons in there.  Then, your custom toolstrip will have the correct button order, no matter what form you drop it on.


www.bungie.net
Post #1622
Posted 06/22/2006 8:51:15 AM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: Forum Members
Last Login: 02/28/2007 12:59:00 PM
Posts: 15, Visits: 42
Thank you.  I apologize for my ignorance, as this is my first WinForms application... 10 years of web programming isn't helping here...
Post #1627
Posted 06/22/2006 8:55:52 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Yesterday @ 10:38:53 PM
Posts: 2,683, Visits: 1,883
Hehe, WinForms does take some getting used to, but once you're there, it will take all of your energy to drag yourself away from WinForms and back to WebForms... WinForms is just so much more flexible and friendlier


www.bungie.net
Post #1628
Posted 06/22/2006 9:12:49 AM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: Forum Members
Last Login: 02/28/2007 12:59:00 PM
Posts: 15, Visits: 42
So should we not use the "Edit Items..." option in the upper right menu of the control?

I was able to override the code manually to put things as they should be, but if I use the designer again it of course blows my changes...

Perhaps I should just use a standard toolstrip, but I sure like what you guys have done for speeding up building such a control set...

Thanks again for your help,

Jason

Post #1633
Posted 06/22/2006 9:24:12 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Yesterday @ 10:38:53 PM
Posts: 2,683, Visits: 1,883
The "Edit Items..." option does move the buttons around within the collection, but since the order is already serialized within the MaintenanceFormToolstrip's InitializeComponent() method, it cannot add code within the Form's InitializeComponent() method that can change the order.  So, you would need a method like this:

private void ReOrderToolStrip()
{
//-- Establish locals
ToolStripButton loNew, loBrowse, loEdit, loDelete, loSave, loUndo;

//-- Save the buttons
loNew = this.maintenanceFormToolStrip1.Items[0];
loBrowse =
this.maintenanceFormToolStrip1.Items[1];
loEdit =
this.maintenanceFormToolStrip1.Items[2];
loDelete =
this.maintenanceFormToolStrip1.Items[3];
loSave =
this.maintenanceFormToolStrip1.Items[4];
loUndo =
this.maintenanceFormToolStrip1.Items[5];

//-- Clear the buttons
this.maintenanceFormToolStrip1.Items.Clear();

//-- Re-add the buttons in the order you want them
this.maintenanceFormToolStrip1.Items.AddRange(new ToolStripItem[]
{ loSave, loUndo, loNew, loEdit, loDelete, loBrowse });
}

You'll also need to add any ToolStripSeparators you want.




www.bungie.net
Post #1634
Posted 06/22/2006 9:25:25 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Yesterday @ 10:38:53 PM
Posts: 2,683, Visits: 1,883
What I will do, is look into the possibility of adding properties that will allow you to set the order of the buttons.


www.bungie.net
Post #1635
Posted 06/22/2006 12:44:06 PM
StrataFrame Beginner

StrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame BeginnerStrataFrame Beginner

Group: Forum Members
Last Login: 02/28/2007 12:59:00 PM
Posts: 15, Visits: 42
As usual you guys have the answers.  Thanks again for the sample code.

Jason

Post #1646
Posted 06/22/2006 12:48:50 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Yesterday @ 10:38:53 PM
Posts: 2,683, Visits: 1,883
If we don't have the answers, then Google does


www.bungie.net
Post #1648
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Ben Chase, Trent L. Taylor, Steve L. Taylor

PermissionsExpand / Collapse