Maintenance Form Toolstrip not saving button positions


Author
Message
StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
If we don't have the answers, then Google does Wink
Jason Stevenson
Jason Stevenson
StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)
Group: Forum Members
Posts: 15, Visits: 43
As usual you guys have the answers.  Thanks again for the sample code.

Jason

StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
What I will do, is look into the possibility of adding properties that will allow you to set the order of the buttons.
StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
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.


Jason Stevenson
Jason Stevenson
StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)
Group: Forum Members
Posts: 15, Visits: 43
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 Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
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 Wink
Jason Stevenson
Jason Stevenson
StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)
Group: Forum Members
Posts: 15, Visits: 43
Thank you.  I apologize for my ignorance, as this is my first WinForms application... 10 years of web programming isn't helping here... Smile
StrataFrame Team
S
StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)StrataFrame Developer (4.6K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
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.
Jason Stevenson
Jason Stevenson
StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)StrataFrame Beginner (23 reputation)
Group: Forum Members
Posts: 15, Visits: 43
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

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