Elements within a user control in C #

0

Good morning,

I am developing an application in C # and I am working with Windows Forms, in which I am using User Controls to be able to use the main menu that I defined as shown in the following photo:

In the menu that displays to press in User opens another sub-menu in which is the option "Add User". This is where I am creating user control. What I would like to know is because it does not match the position where I put the elements in the Control and at the time of initialization it shows them out of date.

Attach a photo:

To achieve that they are aligned perfectly I have to overlay the elements in this case the textbox and the label as I show in the following photo: Someone who can help me because this happens.

Thanks, I had already done a User Control and I had worked it without problems. But this I have not achieved, greetings.

    
asked by Ezequie Lopez 17.08.2018 в 20:50
source

1 answer

1

@EzequieLopez I had the same problem what I do is create an example to the label or texbox: SizeChanged

where it does not matter if you shrink or enlarge it, you will always place the same place you are defining.

I hope I helped you.

  private void lblcliente_SizeChanged(object sender, EventArgs e)
        {
            lbln10.Left = (this.ClientSize.Width - lbln10.Size.Width) / 2;
        }
    
answered by 17.08.2018 / 21:02
source