moving all an app's menus into menus.cs?
-
the vs designer is ok for generating menus but the code gets quite bloaty. is there either a more compact way to generate menus and their click handlers, or alternatively some slick way of collecting them all in a separate "menus.cs" file? TIA ________________________________________ Gosh, it would be awful pleas'n, to reason out the reason, for things I can't explain. Then perhaps I'd deserve ya, and be even worthy of ya.. if I only had a brain!
-
the vs designer is ok for generating menus but the code gets quite bloaty. is there either a more compact way to generate menus and their click handlers, or alternatively some slick way of collecting them all in a separate "menus.cs" file? TIA ________________________________________ Gosh, it would be awful pleas'n, to reason out the reason, for things I can't explain. Then perhaps I'd deserve ya, and be even worthy of ya.. if I only had a brain!
I solve this problem using
#region
directives:#region Menus
private MenuItem mnuFile;
private MenuItem mnuFileNew;
private MenuItem mnuFileOpen;
private MenuItem mnuFileLine1; // A separator.
private MenuItem mnuFileSave;
private MenuItem mnuFileSaveAs;
private MenuItem mnuFileLine2; // Another separator.
private MenuItem mnuFileExit;
#endregion#region Menu events
#region File
private void mnuFileNew_Click(object sender, System.EventArgs e)
{
}private void mnuFileOpen_Click(object sender, System.EventArgs e)
{
}private void mnuFileSave_Click(object sender, System.EventArgs e)
{
}private void mnuFileSaveAs_Click(object sender, System.EventArgs e)
{
}private void mnuFileExit_Click(object sender, System.EventArgs e)
{
}
#endregion
#endregionSince you use Visual Studio, this would hide the menu code, and add more structure to your source file. - Daniël Pelsmaeker
And if your dream is to care for your family, to put food on the table, to provide them with an education and a good home, then maybe suffering through an endless, pointless, boring job will seem to have purpose. And you will realize how even a rock can change the world, simply by remaining obstinately stationary. -Shog9
-
the vs designer is ok for generating menus but the code gets quite bloaty. is there either a more compact way to generate menus and their click handlers, or alternatively some slick way of collecting them all in a separate "menus.cs" file? TIA ________________________________________ Gosh, it would be awful pleas'n, to reason out the reason, for things I can't explain. Then perhaps I'd deserve ya, and be even worthy of ya.. if I only had a brain!
You could just type everything manually. Using the designers isn't magic - they generate code. Instead of using the designer - just type it yourself. Write a class with your menus, instantiate it, and assign that as the menu for your application.
-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++ -----END GEEK CODE BLOCK-----