sa5webber | 21 Mar 2012 03:04
Picon
Favicon

DataGridView setting column width problem

I have a datagridview with 4 columns. The first 3 I've tried to set to a
fixed column width and the last one to a fill as shown below. This works
correctly with MS .net. In mono it distributes the 4 columns into equal
widths. In other words it seems to ignore the AutoSizeMode and width
settings. Anybody have any suggestions?

  dgvLog.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  dgvLog.Columns[0].MinimumWidth = 140;
  dgvLog.Columns[0].Width = 140;
  dgvLog.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  dgvLog.Columns[1].MinimumWidth = 70;
  dgvLog.Columns[1].Width = 70;
  dgvLog.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
  dgvLog.Columns[2].MinimumWidth = 70;
  dgvLog.Columns[2].Width = 70;
  dgvLog.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

--
View this message in context: http://mono.1490590.n4.nabble.com/DataGridView-setting-column-width-problem-tp4491058p4491058.html
Sent from the Mono - WinForms mailing list archive at Nabble.com.
_______________________________________________
Mono-winforms-list maillist  -  Mono-winforms-list <at> lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-winforms-list

Stifu | 21 Mar 2012 19:45
Picon
Favicon
Gravatar

Re: DataGridView setting column width problem

Hi,

I was gonna post a link to bug 590, then realized you're the one who posted
it.
Well, it's just a bug that needs to be fixed, can't say much more than that.
If you're feeling adventurous, feel free to dig into the Mono source code.
That's how I fixed my WinForms pet bugs. Let me know if I can help you
getting started.

sa5webber wrote
> 
> I have a datagridview with 4 columns. The first 3 I've tried to set to a
> fixed column width and the last one to a fill as shown below. This works
> correctly with MS .net. In mono it distributes the 4 columns into equal
> widths. In other words it seems to ignore the AutoSizeMode and width
> settings. Anybody have any suggestions?
> 
>   dgvLog.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
>   dgvLog.Columns[0].MinimumWidth = 140;
>   dgvLog.Columns[0].Width = 140;
>   dgvLog.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
>   dgvLog.Columns[1].MinimumWidth = 70;
>   dgvLog.Columns[1].Width = 70;
>   dgvLog.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
>   dgvLog.Columns[2].MinimumWidth = 70;
>   dgvLog.Columns[2].Width = 70;
>   dgvLog.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
> 

--
(Continue reading)

sa5webber | 24 Mar 2012 17:36
Picon
Favicon

Re: DataGridView setting column width problem

Thanks for the response and offer. Fortunately I found a work around although
I might still take you up on your offer later. At the moment I'm on a
deadline and I need to just get this stuff working.

It turns out the bug wasn't quite as bad as I thought. I had set
AutoGenerateColumns = true, let my datatable populate the datagrid and then
resize the columns as shown in my previous post. As I said in my previous
post this works fine in MS.net but not in mono. Mono seems to ignore the
resize when AutoGenerateColumns = true.

The solution was to set AutoGenerateColumns = false. Create the columns
myself and set the DataPropertyName = field in my datatable.

--
View this message in context: http://mono.1490590.n4.nabble.com/DataGridView-setting-column-width-problem-tp4491058p4501660.html
Sent from the Mono - WinForms mailing list archive at Nabble.com.
_______________________________________________
Mono-winforms-list maillist  -  Mono-winforms-list <at> lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-winforms-list


Gmane