Is there away to drop a usercontrol with parameters into a form?












1















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){}
}









share|improve this question

























  • 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


















1















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){}
}









share|improve this question

























  • 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
















1












1








1


1






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){}
}









share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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





















  • 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














1 Answer
1






active

oldest

votes


















1














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.






share|improve this answer


























  • 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













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
});


}
});














draft saved

draft discarded


















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









1














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.






share|improve this answer


























  • 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


















1














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.






share|improve this answer


























  • 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
















1












1








1







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.






share|improve this answer















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.







share|improve this answer














share|improve this answer



share|improve this answer








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





















  • 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






















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Angular Downloading a file using contenturl with Basic Authentication

Olmecas

Can't read property showImagePicker of undefined in react native iOS