[Mono-list] ListView.cs bugs

Chris Bacon chris.bacon@docobo.co.uk
Thu, 24 Feb 2005 01:42:55 -0000


This is a multi-part message in MIME format.


------=_NextPart_000_07AE_01C51A12.298A4C30
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Hi,

I've discovered a possible bug in ListView.cs.

When a ColumnHeader is added to the ColumnHeaderList its 'owner' member is
not set.
The attached patch fixes this, although I'm not sure if it fixes it in the
correct way.

The attached TestCode.cs shows this and it also shows a bug where the
neither the listview control nor the label control are redrawn when
switching between the two tabPages.
I'm not sure if this is supposed to work; if not, then sorry about bringing
it up!

There is also a curious anomaly in the MS documentation for
"ListView.ColumnHeaderCollection.AddRange" which states that "This method
removes all existing column headers from the collection before inserting new
items". However, this does not seem to be true (in MS or Mono).

Chris

------=_NextPart_000_07AE_01C51A12.298A4C30
Content-Type: application/octet-stream;
	name="ListViewFix.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="ListViewFix.diff"

Index: ListView.cs=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
--- ListView.cs	(revision 41124)=0A=
+++ ListView.cs	(working copy)=0A=
@@ -1731,6 +1731,7 @@=0A=
 			#region Public Methods=0A=
 			public virtual int Add (ColumnHeader value)=0A=
 			{=0A=
+				value.owner =3D this.owner;=0A=
 				return list.Add (value);=0A=
 			}=0A=
 =0A=

------=_NextPart_000_07AE_01C51A12.298A4C30
Content-Type: text/plain;
	name="TestCode.cs"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="TestCode.cs"

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace TabControlTest1
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.TabControl tabControl1;
		private System.Windows.Forms.TabPage tabPage1;
		private System.Windows.Forms.TabPage tabPage2;
		private System.Windows.Forms.ListView listView1;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.ColumnHeader columnHeader1;
		private System.Windows.Forms.ColumnHeader columnHeader2;
		private System.Windows.Forms.ColumnHeader columnHeader3;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components =3D null;

		public Form1()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components !=3D null)=20
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.tabControl1 =3D new System.Windows.Forms.TabControl();
			this.tabPage1 =3D new System.Windows.Forms.TabPage();
			this.tabPage2 =3D new System.Windows.Forms.TabPage();
			this.listView1 =3D new System.Windows.Forms.ListView();
			this.label1 =3D new System.Windows.Forms.Label();
			this.columnHeader1 =3D new System.Windows.Forms.ColumnHeader();
			this.columnHeader2 =3D new System.Windows.Forms.ColumnHeader();
			this.columnHeader3 =3D new System.Windows.Forms.ColumnHeader();
			this.tabControl1.SuspendLayout();
			this.tabPage1.SuspendLayout();
			this.tabPage2.SuspendLayout();
			this.SuspendLayout();
			//=20
			// tabControl1
			//=20
			this.tabControl1.Controls.Add(this.tabPage1);
			this.tabControl1.Controls.Add(this.tabPage2);
			this.tabControl1.Dock =3D System.Windows.Forms.DockStyle.Fill;
			this.tabControl1.Location =3D new System.Drawing.Point(0, 0);
			this.tabControl1.Name =3D "tabControl1";
			this.tabControl1.SelectedIndex =3D 0;
			this.tabControl1.Size =3D new System.Drawing.Size(552, 380);
			this.tabControl1.TabIndex =3D 0;
			//=20
			// tabPage1
			//=20
			this.tabPage1.Controls.Add(this.listView1);
			this.tabPage1.Location =3D new System.Drawing.Point(4, 22);
			this.tabPage1.Name =3D "tabPage1";
			this.tabPage1.Size =3D new System.Drawing.Size(544, 354);
			this.tabPage1.TabIndex =3D 0;
			this.tabPage1.Text =3D "tabPage1";
			//=20
			// tabPage2
			//=20
			this.tabPage2.Controls.Add(this.label1);
			this.tabPage2.Location =3D new System.Drawing.Point(4, 22);
			this.tabPage2.Name =3D "tabPage2";
			this.tabPage2.Size =3D new System.Drawing.Size(544, 354);
			this.tabPage2.TabIndex =3D 1;
			this.tabPage2.Text =3D "tabPage2";
			//=20
			// listView1
			//=20
			this.listView1.Columns.AddRange(new =
System.Windows.Forms.ColumnHeader[] {
																						this.columnHeader1,
																						this.columnHeader2,
																						this.columnHeader3});
			this.listView1.Dock =3D System.Windows.Forms.DockStyle.Fill;
			this.listView1.Location =3D new System.Drawing.Point(0, 0);
			this.listView1.Name =3D "listView1";
			this.listView1.Size =3D new System.Drawing.Size(544, 354);
			this.listView1.TabIndex =3D 0;
			this.listView1.View =3D System.Windows.Forms.View.Details;
			//=20
			// label1
			//=20
			this.label1.Dock =3D System.Windows.Forms.DockStyle.Fill;
			this.label1.Location =3D new System.Drawing.Point(0, 0);
			this.label1.Name =3D "label1";
			this.label1.Size =3D new System.Drawing.Size(544, 354);
			this.label1.TabIndex =3D 0;
			this.label1.Text =3D "label1";
			//=20
			// columnHeader1
			//=20
			this.columnHeader1.Width =3D 100;
			//=20
			// columnHeader2
			//=20
			this.columnHeader2.Width =3D 100;
			//=20
			// columnHeader3
			//=20
			this.columnHeader3.Width =3D 100;
			//=20
			// Form1
			//=20
			this.AutoScaleBaseSize =3D new System.Drawing.Size(5, 13);
			this.ClientSize =3D new System.Drawing.Size(552, 380);
			this.Controls.Add(this.tabControl1);
			this.Name =3D "Form1";
			this.Text =3D "Form1";
			this.tabControl1.ResumeLayout(false);
			this.tabPage1.ResumeLayout(false);
			this.tabPage2.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main()=20
		{
			Application.Run(new Form1());
		}
	}
}

------=_NextPart_000_07AE_01C51A12.298A4C30--