Results 1 to 4 of 4

Thread: User Control, Visual Studio 2019

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2021
    Posts
    3

    User Control, Visual Studio 2019

    Hi,

    Got a few issues as a beginner:

    Using Visual Studio 2019 Windows Form


    I created a windows form added a couple of buttons text boxes etc, than I added User control, played with some buttons in there, inserted to Form 1, coded to show user control on a click event from form 1, all good.

    Than I went add-> new item -> user control , and for some reason the new usercontrol2 has buttons and all the other stuff usercontrol1 has. Nothing in usercontrol2 can be deleted as they belong to usercontrol1. Watched a couple of Youtube videos and no one experiences this. Any help ?

    All thanks

  2. #2
    Frenzied Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    1,557

    Re: User Control, Visual Studio 2019

    It looks as though your new user control is inheriting from usercontrol1, if you check the code behind it might have an Inherits statement. Worth looking to see what it says.

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2021
    Posts
    3

    Re: User Control, Visual Studio 2019

    Quote Originally Posted by PlausiblyDamp View Post
    It looks as though your new user control is inheriting from usercontrol1, if you check the code behind it might have an Inherits statement. Worth looking to see what it says.
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;

    namespace WindowsFormsApp1
    {
    public partial class UserControl1 : UserControl
    {
    public UserControl1()
    {
    InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {

    }
    }
    }

    --------------------------------------------------------------------------------------------


    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;

    namespace WindowsFormsApp1
    {
    public partial class UserControl : System.Windows.Forms.UserControl
    {
    public UserControl()
    {
    InitializeComponent();
    }

    private void checkBox1_CheckedChanged(object sender, EventArgs e)
    {

    }

    private void button1_Click(object sender, EventArgs e)
    {

    }

    private void UserControl_Load(object sender, EventArgs e)
    {

    }
    }
    }

  4. #4

    Thread Starter
    New Member
    Join Date
    Dec 2021
    Posts
    3

    Re: User Control, Visual Studio 2019

    Solved .... I don t know what was it ... i entirely deleted user control 1 and 2 , created them from scratch again and is not happening anymore ... so bad it will be a mystery i might fight again one day ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width