Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DataGridView changes current new row on deactivate
Message
From
07/12/2008 07:06:22
 
 
To
All
General information
Forum:
ASP.NET
Category:
Forms
Title:
DataGridView changes current new row on deactivate
Environment versions
Environment:
C# 3.0
OS:
Vista
Miscellaneous
Thread ID:
01365815
Message ID:
01365815
Views:
65
To reproduce:

1. Run code
2. Press down arrow
3. Click in second form title
4. Click in first form title
5. Enter some characters

Observed:

Entered data appears in first row

Expected:

Entered data should appear in second row

How to fix ?
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Forms;

class TestApplication
{
    static void Main()
    {
        var p = new Form();
        p.IsMdiContainer = true;
        p.WindowState = FormWindowState.Maximized;
        var f1 = new TestForm();
        var f2 = new Form();
        f2.MdiParent = p;
        f1.MdiParent = p;
        f1.Show();
        f2.StartPosition = FormStartPosition.Manual;
        f2.Left = 300;
        f2.Show();
        Application.Run(p);
    }
}

class TestForm : Form
{
    internal DataGridView grid = new DataGridView();
    internal List<Customer> list;

    public TestForm()
    {
        Controls.Add(grid);
        BindingSource BindingSource = new BindingSource();
        list = new List<Customer>();
        list.Add(new Customer() { Name = "test" });
        BindingList<Customer> bindingList = new BindingList<Customer>(list);
        BindingSource.DataSource = bindingList;
        grid.DataSource = bindingList;
    }
}

class Customer
{
    public string Name { get; set; }
}
Andrus
Reply
Map
View

Click here to load this message in the networking platform