[Mono-bugs] [Bug 443609] New: AutoSizeMode = Fill does not work for DataGridViewColumn on setting; AutoSizeColumnModeChanged not raised

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Nov 10 23:09:00 EST 2008


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


           Summary: AutoSizeMode = Fill does not work for DataGridViewColumn
                    on setting; AutoSizeColumnModeChanged not raised
           Product: Mono: Class Libraries
           Version: 2.0
          Platform: Other
        OS/Version: Windows Vista
            Status: NEW
          Severity: Enhancement
          Priority: P5 - None
         Component: Windows.Forms
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: apper at apper.de
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


Created an attachment (id=251196)
 --> (https://bugzilla.novell.com/attachment.cgi?id=251196)
Test case

When having a DataGridView with a column set to "AutoSizeMode=Fill", this works
great, when the DataGridView is resized: the width of the column is set
correctly.

But you have to resize the DataGridView once after setting the AutoSizeMode
property.

The calculation happens in AutoFillColumnsInternal(), which is only called by
AutoResizeColumnsInternal(). This method is called four times: in
OnColumnAddedInternal(), OnColumnRemovedInternal(), OnLayout() and OnResize().
If you first add a column to "Columns" and then set AutoFillMode=Fill, nothing
happens until one of these four Methods is called.

See the attached test case: When starting with adding the column (line 27) and
then setting the AutoSizeMode property to Fill (line 28), the column isn't
resized until the form is resized. Swapping these two lines is a workaround.

I think the problem is the missing "AutoSizeColumnModeChanged" event (see the
setter for AutoSizeMode in DataGridViewColumn.cs). In .NET this event is
raised, if the AutoSizeMode for a column is changed. So after setting
autoSizeMode in the setter of AutoSizeMode, the AutoSizeColumnModeChanged event
should be raised. The code for the setting would be something like this:

DataGridViewAutoSizeColumnMode previousMode = autoSizeMode;
autoSizeMode = value;
if (DataGridView != null)
{
  DataGridView.OnAutoSizeColumnModeChanged(new
DataGridViewAutoSizeColumnModeEventArgs(this, previousMode));")
}

This will raise the event. But AutoResizeColumnsInternal() isn't called. I
would propose, to add a call to AutoResizeColumnsInternal() to
OnAutoSizeColumnModeChanged in DataGridView.cs.


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