Bug 590 - datagridview columnwidth
Summary: datagridview columnwidth
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: Windows.Forms ()
Version: 2.10.x
Hardware: PC Linux
: Lowest normal
Target Milestone: Community
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2011-09-01 20:24 UTC by sa5webber
Modified: 2017-09-01 11:55 UTC (History)
2 users (show)

Tags: mono-community
Is this bug a regression?: ---
Last known good build:


Attachments
The sample program showing the problem (43.49 KB, application/zip)
2011-09-01 20:24 UTC, sa5webber
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 590 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

Description sa5webber 2011-09-01 20:24:42 UTC
Created attachment 237 [details]
The sample program showing the problem

First let me just say that I think mono is awesome. I have the utmost respect for what you guys are doing. Keep up the good work.

So, the basic problem has to do with the datagridview and setting a combination of fixed size columns and fill columns when using a datasource.

My objective was to create a 4 column datagridview where the first 3 columns were a fixed size and the last 4th column adjusted to the size of the datagridview width. I initially put this together using Visual Studio 2010 and .net which all worked without a hitch. I then migrated my application to mono and linux where I ran into the column width problem. In the process of understanding the problem I did run into a few differences regarding mono's datagridview columnwidth behavior, but .net seems to accommodate most of mono's more restrictive implementation which I won't go into here, but would be happy to help resolve.

When I couldn't get the columns to size right I created a simple test program and instead of using a datasource just added the columns as shown below and to my surprise the columns sized and filled the way I wanted.

 dgv.Columns.Add("Col0", "Col0");
 dgv.Columns.Add("Col1", "Col1");
 dgv.Columns.Add("Col2", "Col2");
 dgv.Columns.Add("Col3", "Col3");

 dgv.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
 dgv.Columns[0].Width = colWidths[0];
 dgv.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
 dgv.Columns[1].Width = colWidths[1];
 dgv.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
 dgv.Columns[2].Width = colWidths[2];
 dgv.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

I then changed the simple program back to using a data source like I do in my application and the 4th column quit filling.

 dt = new DataTable();
 dt.Columns.Add("Col0", typeof(string));
 dt.Columns.Add("Col1", typeof(string));
 dt.Columns.Add("Col2", typeof(string));
 dt.Columns.Add("Col3", typeof(string));
 dgv.DataSource = dt;

 dgv.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
 dgv.Columns[0].Width = colWidths[0];
 dgv.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
 dgv.Columns[1].Width = colWidths[1];
 dgv.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
 dgv.Columns[2].Width = colWidths[2];
 dgv.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;