https://bugzilla.novell.com/show_bug.cgi?id=441240


           Summary: TextBox inside containercontrol does not receive focus
           Product: Mono: Class Libraries
           Version: 2.0
          Platform: x86
        OS/Version: Windows Vista
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Windows.Forms
        AssignedTo: [email protected]
        ReportedBy: [EMAIL PROTECTED]
         QAContact: [email protected]
          Found By: ---


To reproduce:

1. Run code below
2. Enter some characters

Observed:

Characters do not appear

Expected:

Characters should appear in textbox in UserControl

Note:

There are also som other anomalies if text is entered to different textboxes
and focus is moved between forms.


Code

using System.Windows.Forms;
using System.Collections.Generic;
using System;

public class Test
{
    static void Main()
    {
        Application.Run(new MainForm());
    }
}

class MainForm : Form
{
    public MainForm()
    {
        WindowState = FormWindowState.Maximized;
        IsMdiContainer = true;
        Form frm = new Childform();
        frm.MdiParent = this;
        frm.Show();
        Form frm2 = new Childform();
        frm2.MdiParent = this;
        frm2.Show();
        frm2.Left = 2000;
    }
}

class Childform : Form
{
    DataGridView grid;
    Control LastFocus = null;

    public Childform()
    {
        ToolStripContainer tc = new ToolStripContainer();

        grid = new DataGridView();
        grid.Columns.Add(new DataGridViewTextBoxColumn());
        grid.EditMode = DataGridViewEditMode.EditOnEnter;
        grid.Top = 120;
        grid.Height = 300;
        Controls.Add(tc);
        tc.ContentPanel.Controls.Add(new MyUserControl());

        tc.ContentPanel.Controls.Add(grid);
    }

    protected override void OnActivated(EventArgs e)
    {
        base.OnActivated(e);
        if (this.LastFocus != null)
        {
            grid.Focus();
            this.LastFocus.Focus();
        }
    }

    protected override void OnDeactivate(EventArgs e)
    {
        base.OnDeactivate(e);
        this.LastFocus = this.ActiveControl;
        while (LastFocus is IContainerControl)
            LastFocus = ((IContainerControl)LastFocus).ActiveControl;
    }
}

class MyUserControl : UserControl
{
    internal MyUserControl()
    {
        Height = 100;
        Controls.Add(new TextBox());
    }
}


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
_______________________________________________
mono-bugs maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to