Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DataGridView changes current new row on deactivate
Message
De
07/12/2008 07:06:22
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Titre:
DataGridView changes current new row on deactivate
Versions des environnements
Environment:
C# 3.0
OS:
Vista
Divers
Thread ID:
01365815
Message ID:
01365815
Vues:
63
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
Répondre
Fil
Voir

Click here to load this message in the networking platform