Problem with clicking a Textbox inside a Child Form

Asked

Viewed 29 times

0

Good Afternoon!

I have the following code in my application:

using System;
using System.Drawing;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    static class Program
    {
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Form formPrincipal = new Form();
            formPrincipal.IsMdiContainer = true;

            Form formFilho = new Form() { MdiParent = formPrincipal };            

            Form formNeto = new Form() { TopLevel = false };
            formNeto.Controls.Add(new TextBox() { Location = new Point(10, 10) });
            formNeto.Show();

            formFilho.Controls.Add(formNeto);
            formFilho.Show();

            Application.Run(formPrincipal);
        }
    }
}

The problem I’ve been facing is that Textbox within the formNeto does not accept the input by mouse, if I click in the middle of it, for example, the cursor is not placed where I clicked, getting at the beginning of the Textbox. The same does not reproduce when Textbox is like a child of formPrincipal or in the formFilm

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.