none
How to customize a form and use it in windows form ? RRS feed

  • Question

  • Hello,

    my problem is very simple ! i want know how to create a custom (in term of design view) window Form (probably by using WPF) and then use it like custom control on Windows Form platform ?

    Thank you.


    Tuesday, October 22, 2019 12:04 PM

Answers

  • Hi MohanedAmine,

    Thank you for posting here.

    According to your description, it seems that you want to customize a control and use it in the form.

    Here are the steps to customize the control:

    Add => New Item => Choose User Control => Add controls and write code ( I used a button and a textbok to make up a user control. ) => Build the Project.

    Then you can use it like a normal control.

    Code in UserControl1:

        public partial class UserControl1 : UserControl
        {
            public UserControl1()
            {
                InitializeComponent();
            }
    
            private void Button1_Click(object sender, EventArgs e)
            {
                textBox1.Text = "ok";
            }
        }
    If I misunderstood what you mean, please let me know.

    Best regards,
    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by MohanedAmine Wednesday, October 23, 2019 9:55 AM
    Wednesday, October 23, 2019 5:21 AM

All replies

  • Hi MohanedAmine,

    Thank you for posting here.

    According to your description, it seems that you want to customize a control and use it in the form.

    Here are the steps to customize the control:

    Add => New Item => Choose User Control => Add controls and write code ( I used a button and a textbok to make up a user control. ) => Build the Project.

    Then you can use it like a normal control.

    Code in UserControl1:

        public partial class UserControl1 : UserControl
        {
            public UserControl1()
            {
                InitializeComponent();
            }
    
            private void Button1_Click(object sender, EventArgs e)
            {
                textBox1.Text = "ok";
            }
        }
    If I misunderstood what you mean, please let me know.

    Best regards,
    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by MohanedAmine Wednesday, October 23, 2019 9:55 AM
    Wednesday, October 23, 2019 5:21 AM
  • Thank you for your answer :)

    That's nice but i want to customize a Form not a control ! so what can i do in this situation ?

    Wednesday, October 23, 2019 10:03 AM