Is there away to drop a usercontrol with parameters into a form?
I have a usercontrol with a readonly parameter. Is there away to drop this usercontrol in winforms from toolbox (filling in the parameter of the constructor)?
I want to make my program as user friendly as possible. By this i mean when the "client" wants the designt to change he/she has to just drag and drop from the toolbox without going into the code. Now i'm creating and positioning the usercontrol in my class. I also could make diffrent usercontrols per enum and do it this way.
public partial class MyUserControl : UserControl{
public MyUserControl(Enum type){}
}
c# winforms parameters drag-and-drop user-controls
add a comment |
I have a usercontrol with a readonly parameter. Is there away to drop this usercontrol in winforms from toolbox (filling in the parameter of the constructor)?
I want to make my program as user friendly as possible. By this i mean when the "client" wants the designt to change he/she has to just drag and drop from the toolbox without going into the code. Now i'm creating and positioning the usercontrol in my class. I also could make diffrent usercontrols per enum and do it this way.
public partial class MyUserControl : UserControl{
public MyUserControl(Enum type){}
}
c# winforms parameters drag-and-drop user-controls
no, use property instead constructor if you wana use it at design time
– Selvin
Jan 1 at 21:28
All the public Properties of your UC will be listed in the Property window of the Form's Designer. A User can then make use of the Property window to customize the control's appearance/behaviour etc. Also, see the EditorBrowsable, Browsable and Category Attributes.
– Jimi
Jan 1 at 22:04
add a comment |
I have a usercontrol with a readonly parameter. Is there away to drop this usercontrol in winforms from toolbox (filling in the parameter of the constructor)?
I want to make my program as user friendly as possible. By this i mean when the "client" wants the designt to change he/she has to just drag and drop from the toolbox without going into the code. Now i'm creating and positioning the usercontrol in my class. I also could make diffrent usercontrols per enum and do it this way.
public partial class MyUserControl : UserControl{
public MyUserControl(Enum type){}
}
c# winforms parameters drag-and-drop user-controls
I have a usercontrol with a readonly parameter. Is there away to drop this usercontrol in winforms from toolbox (filling in the parameter of the constructor)?
I want to make my program as user friendly as possible. By this i mean when the "client" wants the designt to change he/she has to just drag and drop from the toolbox without going into the code. Now i'm creating and positioning the usercontrol in my class. I also could make diffrent usercontrols per enum and do it this way.
public partial class MyUserControl : UserControl{
public MyUserControl(Enum type){}
}
c# winforms parameters drag-and-drop user-controls
c# winforms parameters drag-and-drop user-controls
edited Jan 1 at 21:29
Maxime C.
asked Jan 1 at 21:22
Maxime C.Maxime C.
63
63
no, use property instead constructor if you wana use it at design time
– Selvin
Jan 1 at 21:28
All the public Properties of your UC will be listed in the Property window of the Form's Designer. A User can then make use of the Property window to customize the control's appearance/behaviour etc. Also, see the EditorBrowsable, Browsable and Category Attributes.
– Jimi
Jan 1 at 22:04
add a comment |
no, use property instead constructor if you wana use it at design time
– Selvin
Jan 1 at 21:28
All the public Properties of your UC will be listed in the Property window of the Form's Designer. A User can then make use of the Property window to customize the control's appearance/behaviour etc. Also, see the EditorBrowsable, Browsable and Category Attributes.
– Jimi
Jan 1 at 22:04
no, use property instead constructor if you wana use it at design time
– Selvin
Jan 1 at 21:28
no, use property instead constructor if you wana use it at design time
– Selvin
Jan 1 at 21:28
All the public Properties of your UC will be listed in the Property window of the Form's Designer. A User can then make use of the Property window to customize the control's appearance/behaviour etc. Also, see the EditorBrowsable, Browsable and Category Attributes.
– Jimi
Jan 1 at 22:04
All the public Properties of your UC will be listed in the Property window of the Form's Designer. A User can then make use of the Property window to customize the control's appearance/behaviour etc. Also, see the EditorBrowsable, Browsable and Category Attributes.
– Jimi
Jan 1 at 22:04
add a comment |
1 Answer
1
active
oldest
votes
Make sure your control also has a default constructor, i.e. a constructor with no parameters. You can keep the current parametrized constructor if you intend to create controls in code. If you add a public property exposing your enum, then it will appear in the properties window of your control. Values you set there will be persisted, i.e., the form will remember this value.
If the user control is in the current project, once successfully compiled, the Toolbox Window will automatically list your control at the very top.
If the UserControl is in another project, you must edit the Toolbox and add a reference to the other assembly to add the controls to the Toolbox.
You can keep the current parametrized constructor. - which will be never used if Control would be used from genereted code("dropped" from toolbox)
– Selvin
Jan 1 at 21:33
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53999041%2fis-there-away-to-drop-a-usercontrol-with-parameters-into-a-form%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Make sure your control also has a default constructor, i.e. a constructor with no parameters. You can keep the current parametrized constructor if you intend to create controls in code. If you add a public property exposing your enum, then it will appear in the properties window of your control. Values you set there will be persisted, i.e., the form will remember this value.
If the user control is in the current project, once successfully compiled, the Toolbox Window will automatically list your control at the very top.
If the UserControl is in another project, you must edit the Toolbox and add a reference to the other assembly to add the controls to the Toolbox.
You can keep the current parametrized constructor. - which will be never used if Control would be used from genereted code("dropped" from toolbox)
– Selvin
Jan 1 at 21:33
add a comment |
Make sure your control also has a default constructor, i.e. a constructor with no parameters. You can keep the current parametrized constructor if you intend to create controls in code. If you add a public property exposing your enum, then it will appear in the properties window of your control. Values you set there will be persisted, i.e., the form will remember this value.
If the user control is in the current project, once successfully compiled, the Toolbox Window will automatically list your control at the very top.
If the UserControl is in another project, you must edit the Toolbox and add a reference to the other assembly to add the controls to the Toolbox.
You can keep the current parametrized constructor. - which will be never used if Control would be used from genereted code("dropped" from toolbox)
– Selvin
Jan 1 at 21:33
add a comment |
Make sure your control also has a default constructor, i.e. a constructor with no parameters. You can keep the current parametrized constructor if you intend to create controls in code. If you add a public property exposing your enum, then it will appear in the properties window of your control. Values you set there will be persisted, i.e., the form will remember this value.
If the user control is in the current project, once successfully compiled, the Toolbox Window will automatically list your control at the very top.
If the UserControl is in another project, you must edit the Toolbox and add a reference to the other assembly to add the controls to the Toolbox.
Make sure your control also has a default constructor, i.e. a constructor with no parameters. You can keep the current parametrized constructor if you intend to create controls in code. If you add a public property exposing your enum, then it will appear in the properties window of your control. Values you set there will be persisted, i.e., the form will remember this value.
If the user control is in the current project, once successfully compiled, the Toolbox Window will automatically list your control at the very top.
If the UserControl is in another project, you must edit the Toolbox and add a reference to the other assembly to add the controls to the Toolbox.
edited Jan 2 at 12:55
answered Jan 1 at 21:30
Olivier Jacot-DescombesOlivier Jacot-Descombes
68.3k890140
68.3k890140
You can keep the current parametrized constructor. - which will be never used if Control would be used from genereted code("dropped" from toolbox)
– Selvin
Jan 1 at 21:33
add a comment |
You can keep the current parametrized constructor. - which will be never used if Control would be used from genereted code("dropped" from toolbox)
– Selvin
Jan 1 at 21:33
You can keep the current parametrized constructor. - which will be never used if Control would be used from genereted code("dropped" from toolbox)
– Selvin
Jan 1 at 21:33
You can keep the current parametrized constructor. - which will be never used if Control would be used from genereted code("dropped" from toolbox)
– Selvin
Jan 1 at 21:33
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53999041%2fis-there-away-to-drop-a-usercontrol-with-parameters-into-a-form%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
no, use property instead constructor if you wana use it at design time
– Selvin
Jan 1 at 21:28
All the public Properties of your UC will be listed in the Property window of the Form's Designer. A User can then make use of the Property window to customize the control's appearance/behaviour etc. Also, see the EditorBrowsable, Browsable and Category Attributes.
– Jimi
Jan 1 at 22:04