How to expose ALL properties of a Control in a class derived from Form?












-1














I have class derived from Form and it contains a TableLayoutPanel and in it one Label and one Panel. When I create instance of this Form, all properties and events of controls in design editor are read-only. Is there any way how to expose whole object for editing? I know that I can expose properties one by one, but that is not the best way in case when you want all of them.










share|improve this question




















  • 1




    "I have UserControl derived from Form" You really have a public class Usercontrol : Form? Are you dropping this on another form, or are you using it as a stand-alone form? Can you show how you declared the properties and events? Are the table layout panel and label, etc marked as public accessibility?
    – Ron Beyer
    Nov 12 at 18:57










  • The controls like Label or Panel will be private so they will not be visible in inherited class.
    – dee
    Nov 12 at 19:01










  • I am using it as a stand-alone form in my MDI Parent form. And yes, all controls are public.
    – Milan Fornůsek
    Nov 12 at 19:03










  • @MilanFornůsek If you have a form, and not a user control, then you should make that clear in your question, rather than saying you have a user control when you have a form.
    – Servy
    Nov 12 at 19:19










  • A form should not be exposing it's private controls like this. The whole idea of having this class to to encapsulate access to those controls.
    – Servy
    Nov 12 at 19:21
















-1














I have class derived from Form and it contains a TableLayoutPanel and in it one Label and one Panel. When I create instance of this Form, all properties and events of controls in design editor are read-only. Is there any way how to expose whole object for editing? I know that I can expose properties one by one, but that is not the best way in case when you want all of them.










share|improve this question




















  • 1




    "I have UserControl derived from Form" You really have a public class Usercontrol : Form? Are you dropping this on another form, or are you using it as a stand-alone form? Can you show how you declared the properties and events? Are the table layout panel and label, etc marked as public accessibility?
    – Ron Beyer
    Nov 12 at 18:57










  • The controls like Label or Panel will be private so they will not be visible in inherited class.
    – dee
    Nov 12 at 19:01










  • I am using it as a stand-alone form in my MDI Parent form. And yes, all controls are public.
    – Milan Fornůsek
    Nov 12 at 19:03










  • @MilanFornůsek If you have a form, and not a user control, then you should make that clear in your question, rather than saying you have a user control when you have a form.
    – Servy
    Nov 12 at 19:19










  • A form should not be exposing it's private controls like this. The whole idea of having this class to to encapsulate access to those controls.
    – Servy
    Nov 12 at 19:21














-1












-1








-1







I have class derived from Form and it contains a TableLayoutPanel and in it one Label and one Panel. When I create instance of this Form, all properties and events of controls in design editor are read-only. Is there any way how to expose whole object for editing? I know that I can expose properties one by one, but that is not the best way in case when you want all of them.










share|improve this question















I have class derived from Form and it contains a TableLayoutPanel and in it one Label and one Panel. When I create instance of this Form, all properties and events of controls in design editor are read-only. Is there any way how to expose whole object for editing? I know that I can expose properties one by one, but that is not the best way in case when you want all of them.







c# winforms tablelayoutpanel






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 at 20:17









dee

10.4k32444




10.4k32444










asked Nov 12 at 18:47









Milan Fornůsek

93




93








  • 1




    "I have UserControl derived from Form" You really have a public class Usercontrol : Form? Are you dropping this on another form, or are you using it as a stand-alone form? Can you show how you declared the properties and events? Are the table layout panel and label, etc marked as public accessibility?
    – Ron Beyer
    Nov 12 at 18:57










  • The controls like Label or Panel will be private so they will not be visible in inherited class.
    – dee
    Nov 12 at 19:01










  • I am using it as a stand-alone form in my MDI Parent form. And yes, all controls are public.
    – Milan Fornůsek
    Nov 12 at 19:03










  • @MilanFornůsek If you have a form, and not a user control, then you should make that clear in your question, rather than saying you have a user control when you have a form.
    – Servy
    Nov 12 at 19:19










  • A form should not be exposing it's private controls like this. The whole idea of having this class to to encapsulate access to those controls.
    – Servy
    Nov 12 at 19:21














  • 1




    "I have UserControl derived from Form" You really have a public class Usercontrol : Form? Are you dropping this on another form, or are you using it as a stand-alone form? Can you show how you declared the properties and events? Are the table layout panel and label, etc marked as public accessibility?
    – Ron Beyer
    Nov 12 at 18:57










  • The controls like Label or Panel will be private so they will not be visible in inherited class.
    – dee
    Nov 12 at 19:01










  • I am using it as a stand-alone form in my MDI Parent form. And yes, all controls are public.
    – Milan Fornůsek
    Nov 12 at 19:03










  • @MilanFornůsek If you have a form, and not a user control, then you should make that clear in your question, rather than saying you have a user control when you have a form.
    – Servy
    Nov 12 at 19:19










  • A form should not be exposing it's private controls like this. The whole idea of having this class to to encapsulate access to those controls.
    – Servy
    Nov 12 at 19:21








1




1




"I have UserControl derived from Form" You really have a public class Usercontrol : Form? Are you dropping this on another form, or are you using it as a stand-alone form? Can you show how you declared the properties and events? Are the table layout panel and label, etc marked as public accessibility?
– Ron Beyer
Nov 12 at 18:57




"I have UserControl derived from Form" You really have a public class Usercontrol : Form? Are you dropping this on another form, or are you using it as a stand-alone form? Can you show how you declared the properties and events? Are the table layout panel and label, etc marked as public accessibility?
– Ron Beyer
Nov 12 at 18:57












The controls like Label or Panel will be private so they will not be visible in inherited class.
– dee
Nov 12 at 19:01




The controls like Label or Panel will be private so they will not be visible in inherited class.
– dee
Nov 12 at 19:01












I am using it as a stand-alone form in my MDI Parent form. And yes, all controls are public.
– Milan Fornůsek
Nov 12 at 19:03




I am using it as a stand-alone form in my MDI Parent form. And yes, all controls are public.
– Milan Fornůsek
Nov 12 at 19:03












@MilanFornůsek If you have a form, and not a user control, then you should make that clear in your question, rather than saying you have a user control when you have a form.
– Servy
Nov 12 at 19:19




@MilanFornůsek If you have a form, and not a user control, then you should make that clear in your question, rather than saying you have a user control when you have a form.
– Servy
Nov 12 at 19:19












A form should not be exposing it's private controls like this. The whole idea of having this class to to encapsulate access to those controls.
– Servy
Nov 12 at 19:21




A form should not be exposing it's private controls like this. The whole idea of having this class to to encapsulate access to those controls.
– Servy
Nov 12 at 19:21












2 Answers
2






active

oldest

votes


















1














Have a look here:




Avoid Visual Inheritance



The TableLayoutPanel control does not support visual inheritance in
the Windows Forms Designer. A TableLayoutPanel control in a
derived class appears as locked at design time.







share|improve this answer





















  • Thank you, that was the cause of the problem. After I removed TableLayoutPanel and keep only Label and Panel all is working now.
    – Milan Fornůsek
    Nov 12 at 20:18





















-1














You can use internal or make a getter method / property



public Label GetLabel() => return someLabel;


or



public Label MyLabel { get { return someLabel; } }


or



internal Label someLabel;





share|improve this answer





















    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%2f53268304%2fhow-to-expose-all-properties-of-a-control-in-a-class-derived-from-form%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Have a look here:




    Avoid Visual Inheritance



    The TableLayoutPanel control does not support visual inheritance in
    the Windows Forms Designer. A TableLayoutPanel control in a
    derived class appears as locked at design time.







    share|improve this answer





















    • Thank you, that was the cause of the problem. After I removed TableLayoutPanel and keep only Label and Panel all is working now.
      – Milan Fornůsek
      Nov 12 at 20:18


















    1














    Have a look here:




    Avoid Visual Inheritance



    The TableLayoutPanel control does not support visual inheritance in
    the Windows Forms Designer. A TableLayoutPanel control in a
    derived class appears as locked at design time.







    share|improve this answer





















    • Thank you, that was the cause of the problem. After I removed TableLayoutPanel and keep only Label and Panel all is working now.
      – Milan Fornůsek
      Nov 12 at 20:18
















    1












    1








    1






    Have a look here:




    Avoid Visual Inheritance



    The TableLayoutPanel control does not support visual inheritance in
    the Windows Forms Designer. A TableLayoutPanel control in a
    derived class appears as locked at design time.







    share|improve this answer












    Have a look here:




    Avoid Visual Inheritance



    The TableLayoutPanel control does not support visual inheritance in
    the Windows Forms Designer. A TableLayoutPanel control in a
    derived class appears as locked at design time.








    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 12 at 20:16









    dee

    10.4k32444




    10.4k32444












    • Thank you, that was the cause of the problem. After I removed TableLayoutPanel and keep only Label and Panel all is working now.
      – Milan Fornůsek
      Nov 12 at 20:18




















    • Thank you, that was the cause of the problem. After I removed TableLayoutPanel and keep only Label and Panel all is working now.
      – Milan Fornůsek
      Nov 12 at 20:18


















    Thank you, that was the cause of the problem. After I removed TableLayoutPanel and keep only Label and Panel all is working now.
    – Milan Fornůsek
    Nov 12 at 20:18






    Thank you, that was the cause of the problem. After I removed TableLayoutPanel and keep only Label and Panel all is working now.
    – Milan Fornůsek
    Nov 12 at 20:18















    -1














    You can use internal or make a getter method / property



    public Label GetLabel() => return someLabel;


    or



    public Label MyLabel { get { return someLabel; } }


    or



    internal Label someLabel;





    share|improve this answer


























      -1














      You can use internal or make a getter method / property



      public Label GetLabel() => return someLabel;


      or



      public Label MyLabel { get { return someLabel; } }


      or



      internal Label someLabel;





      share|improve this answer
























        -1












        -1








        -1






        You can use internal or make a getter method / property



        public Label GetLabel() => return someLabel;


        or



        public Label MyLabel { get { return someLabel; } }


        or



        internal Label someLabel;





        share|improve this answer












        You can use internal or make a getter method / property



        public Label GetLabel() => return someLabel;


        or



        public Label MyLabel { get { return someLabel; } }


        or



        internal Label someLabel;






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 12 at 20:04









        nnty

        343




        343






























            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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2f53268304%2fhow-to-expose-all-properties-of-a-control-in-a-class-derived-from-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

            List item for chat from Array inside array React Native

            Thiostrepton

            Caerphilly