[Mono-bugs] [Bug 441240] New: TextBox inside containercontrol does not receive focus
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Mon Nov 3 16:09:22 EST 2008
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: mono-bugs at lists.ximian.com
ReportedBy: kobruleht2 at hot.ee
QAContact: mono-bugs at lists.ximian.com
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.
More information about the mono-bugs
mailing list