[Mono-bugs] [Bug 486640] New: DataGridView: Event Differences between mono and .NET with DataGridViewCell

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Mar 18 19:00:52 EDT 2009


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


           Summary: DataGridView: Event Differences between mono and .NET
                    with DataGridViewCell
    Classification: Mono
           Product: Mono: Class Libraries
           Version: SVN
          Platform: i686
        OS/Version: Ubuntu
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Windows.Forms
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: tom_hindle at sil.org
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.7)
Gecko/2009030422 Ubuntu/8.04 (hardy) Firefox/3.0.7

Sample code showing Event differences:

In particular DataGridViewCell::OnEnter doesn't seem to be called when
selecting a Cell.

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

public class MyDataGridViewColumn : DataGridViewColumn
{
    public MyDataGridViewColumn() : base(new MyDataGridViewCell())
    {

    }
}

public class MyDataGridViewCell : DataGridViewCell
{
    public static int g_instance = 0;
    public int m_instance;

    public int m_eventCount = 0;

    public int m_enterEventCount = 0;

    public static MyDataGridViewCell s_lastCell;    
    public MyDataGridViewCell()
    {        
        m_instance = g_instance++;
        s_lastCell = this;
        Console.WriteLine("MyDataGridViewCell {0}", m_instance);

    }

    protected override void OnDataGridViewChanged()
    {    
        m_eventCount++;
        base.OnDataGridViewChanged();

        if (DataGridView != null)
        {
            DataGridView.ColumnWidthChanged += new
DataGridViewColumnEventHandler(OnColumnWidthChanged);
            DataGridView.RowHeightChanged += new
DataGridViewRowEventHandler(OnRowHeightChanged);
            DataGridView.ColumnStateChanged += new
DataGridViewColumnStateChangedEventHandler(OnColumnStateChanged);
            DataGridView.RowStateChanged += new
DataGridViewRowStateChangedEventHandler(OnRowStateChanged);
        }

        Console.WriteLine("OnDataGridViewChanged {0} {1}", m_instance,
m_eventCount);
    }

    protected override void OnEnter(int rowIndex, bool throughMouseClick)
    {
        m_enterEventCount++;
        base.OnEnter(rowIndex, throughMouseClick);
        m_eventCount++;
        Console.WriteLine("OnEnter {0} {1}", m_instance, m_eventCount);
    }

    internal void OnColumnWidthChanged(object sender,
DataGridViewColumnEventArgs e)
    {
        m_eventCount++;
        Console.WriteLine("OnColumnWidthChanged {0} {1}", m_instance,
m_eventCount);
    }

    internal void OnRowHeightChanged(object sender, DataGridViewRowEventArgs e)
    {
        m_eventCount++;
        Console.WriteLine("OnRowHeightChanged {0} {1}", m_instance,
m_eventCount);
    }

    protected void OnColumnStateChanged(object sender,
DataGridViewColumnStateChangedEventArgs e)
    {
        m_eventCount++;
        Console.WriteLine("OnColumnStateChanged {0} {1}", m_instance,
m_eventCount);
    }

    protected void OnRowStateChanged(object sender,
DataGridViewRowStateChangedEventArgs e)
    {
        m_eventCount++;
        Console.WriteLine("OnRowStateChanged {0} {1}", m_instance,
m_eventCount);
    }

}

public class DataGridViewEventsTest
{
    [STAThreadAttribute()]
    static void Main()
    {                
        DataGridView dgv = new DataGridView();
        dgv.AllowUserToAddRows = false;
        MyDataGridViewColumn column = new MyDataGridViewColumn();
        dgv.Columns.Add(column);        
        dgv.RowCount = 1;

        // Assert(MyDataGridViewCell.s_lastCell.m_eventcount == 1, "A1");
        Console.WriteLine("MyDataGridViewCell m_eventCount = {0}",
MyDataGridViewCell.s_lastCell.m_eventCount);

        // Assert(MyDataGridViewCell.g_instance == 2, "B1");
        Console.WriteLine("MyDataGridViewCell MyDataGridViewCell.g_instance =
{0}", MyDataGridViewCell.g_instance);

        dgv.RowCount = 2;

        // Assert(MyDataGridViewCell.s_lastCell.m_eventcount == 1, "A2");
        Console.WriteLine("MyDataGridViewCell m_eventCount = {0}",
MyDataGridViewCell.s_lastCell.m_eventCount);

        dgv.Rows[0].Visible = false;

        // Assert(MyDataGridViewCell.s_lastCell.m_eventcount == 2, "A3");
        Console.WriteLine("MyDataGridViewCell m_eventCount = {0}",
MyDataGridViewCell.s_lastCell.m_eventCount);

        dgv.Rows[0].Visible = true;

        // Assert(MyDataGridViewCell.s_lastCell.m_eventcount == 3, "A4");
        Console.WriteLine("MyDataGridViewCell m_eventCount = {0}",
MyDataGridViewCell.s_lastCell.m_eventCount);

        dgv.Rows[1].Visible = false;
        // Assert(MyDataGridViewCell.s_lastCell.m_eventcount == 2, "A5");
        Console.WriteLine("MyDataGridViewCell m_eventCount = {0}",
MyDataGridViewCell.s_lastCell.m_eventCount);

        dgv.Rows[0].Height = 10;
        // Assert(MyDataGridViewCell.s_lastCell.m_eventcount == 3, "A6");
        Console.WriteLine("MyDataGridViewCell m_eventCount = {0}",
MyDataGridViewCell.s_lastCell.m_eventCount);

        dgv.Columns[0].Width = 10;
        // Assert(MyDataGridViewCell.s_lastCell.m_eventcount == 4, "A7");
        Console.WriteLine("MyDataGridViewCell m_eventCount = {0}",
MyDataGridViewCell.s_lastCell.m_eventCount);

        dgv.Rows[1].Visible = true;
        dgv.CurrentCell = dgv.Rows[1].Cells[0];
        // Assert(MyDataGridViewCell.s_lastCell.m_eventcount == 6, "A8");
        Console.WriteLine("MyDataGridViewCell m_eventCount = {0}",
MyDataGridViewCell.s_lastCell.m_eventCount);

        // Assert(MyDataGridViewCell.s_lastCell.m_enterEventCount == 1, "C1");
        Console.WriteLine("MyDataGridViewCell m_enterEventCount = {0}",
MyDataGridViewCell.s_lastCell.m_enterEventCount);        
    }
}

Reproducible: Always

Steps to Reproduce:
1. Compile and run sample code
2.
3.
Actual Results:  
MyDataGridViewCell 0
MyDataGridViewCell 1
OnDataGridViewChanged 1 1
MyDataGridViewCell 2
OnDataGridViewChanged 2 1
MyDataGridViewCell 3
OnDataGridViewChanged 3 1
MyDataGridViewCell m_eventCount = 1
MyDataGridViewCell MyDataGridViewCell.g_instance = 4
MyDataGridViewCell 4
OnDataGridViewChanged 4 1
MyDataGridViewCell 5
OnDataGridViewChanged 5 1
MyDataGridViewCell m_eventCount = 1
OnRowStateChanged 1 2
OnRowStateChanged 2 2
OnRowStateChanged 3 2
OnRowStateChanged 4 2
OnRowStateChanged 5 2
MyDataGridViewCell m_eventCount = 2
OnRowStateChanged 1 3
OnRowStateChanged 2 3
OnRowStateChanged 3 3
OnRowStateChanged 4 3
OnRowStateChanged 5 3
MyDataGridViewCell m_eventCount = 3
OnRowStateChanged 1 4
OnRowStateChanged 2 4
OnRowStateChanged 3 4
OnRowStateChanged 4 4
OnRowStateChanged 5 4
MyDataGridViewCell m_eventCount = 4
OnRowHeightChanged 1 5
OnRowHeightChanged 2 5
OnRowHeightChanged 3 5
OnRowHeightChanged 4 5
OnRowHeightChanged 5 5
MyDataGridViewCell m_eventCount = 5
OnColumnWidthChanged 1 6
OnColumnWidthChanged 2 6
OnColumnWidthChanged 3 6
OnColumnWidthChanged 4 6
OnColumnWidthChanged 5 6
MyDataGridViewCell m_eventCount = 6
OnRowStateChanged 1 7
OnRowStateChanged 2 7
OnRowStateChanged 3 7
OnRowStateChanged 4 7
OnRowStateChanged 5 7
MyDataGridViewCell m_eventCount = 7
MyDataGridViewCell m_enterEventCount = 0

Expected Results:  
MyDataGridViewCell 0
MyDataGridViewCell 1
OnDataGridViewChanged 1 1
MyDataGridViewCell m_eventCount = 1
MyDataGridViewCell MyDataGridViewCell.g_instance = 2
MyDataGridViewCell 2
OnDataGridViewChanged 2 1
MyDataGridViewCell m_eventCount = 1
MyDataGridViewCell 3
OnDataGridViewChanged 3 1
OnRowStateChanged 1 2
OnRowStateChanged 2 2
OnRowStateChanged 3 2
MyDataGridViewCell m_eventCount = 2
OnRowStateChanged 1 3
OnRowStateChanged 2 3
OnRowStateChanged 3 3
MyDataGridViewCell m_eventCount = 3
MyDataGridViewCell 4
OnDataGridViewChanged 4 1
OnRowStateChanged 1 4
OnRowStateChanged 2 4
OnRowStateChanged 3 4
OnRowStateChanged 4 2
MyDataGridViewCell m_eventCount = 2
OnRowHeightChanged 1 5
OnRowHeightChanged 2 5
OnRowHeightChanged 3 5
OnRowHeightChanged 4 3
MyDataGridViewCell m_eventCount = 3
OnColumnWidthChanged 1 6
OnColumnWidthChanged 2 6
OnColumnWidthChanged 3 6
OnColumnWidthChanged 4 4
MyDataGridViewCell m_eventCount = 4
OnRowStateChanged 1 7
OnRowStateChanged 2 7
OnRowStateChanged 3 7
OnRowStateChanged 4 5
OnEnter 4 6
MyDataGridViewCell m_eventCount = 6
MyDataGridViewCell m_enterEventCount = 1

-- 
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