custom user control may not be the correct wording as it brings me to placing something in the toolbox. What I think I am really looking for is some option that allows me to do an add new item but instead of selecting "User Control" I would select "Menu Panel"
Say I wanted to create a new user control that I name NetworkConnectionView the code currently look like this:
public partial class NetworkConnectionView : UserContrl
however what I am hoping for is to use the "add new item" option to get a class signature that would look like this:
public partial class NetworkConnectionView : MenuPanel
The main reason for doing this is to inherit the transparency, size and other elements that are used repeatedly but also so I can have a function that has a parameter of MenuPanel. So something like this:
private void InsertMenuOption(MenuPanel curMenuPanel, string name){
curMenuPanel.Name = name
Button menuOptionBtn = new Button()
// initialization of menuOptionBtn parameters...
menuOptionsPanel.controls.Add(menuOptionBtn )
// ...
}
EDIT:
based on Jimi's comment I was able to export a template however when I do an add item I am still seeing that it is inheriting directly from UserControl. With that said, it loads into my project with the expected size, backcolor etc. I am just not showing that it inherits from MenuPanel instead of UserControl.
Image of the template that is added to the project via "Add Item"
I was way over complicating this. What I ended up needing to do was to create a "template" user control that I named MenuPanelView which inherited from user control. after setting all the desired parameters (ie size, transparency, etc) I then when into any object that I wanted to inherit from MenuPanelView and simply overwrote the UserControl with MenuPanelView.
So this:
public partial class TestUserControl : UserControl
{
public TestUserControl()
{
InitializeComponent();
}
}
Would just become this (and work as desired):
public partial class TestUserControl : MenuPanelView
{
public TestUserControl()
{
InitializeComponent();
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.