| | | StrataFrame 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 |
| | | | 
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 |
| | | | StrataFrame 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... |
| | | | 
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 |
| | | | StrataFrame 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 |
| | | | 
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 |
| | | | 
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 |
| | | | StrataFrame 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 |
| | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: Yesterday @ 10:38:53 PM Posts: 2,683, Visits: 1,883 |
| | |
|
|