From a46f1f61071fd0ac476c51a5309361296487c5dc Mon Sep 17 00:00:00 2001 From: Gert Driesen Date: Thu, 1 Mar 2007 21:53:20 +0000 Subject: * ListView.cs: Add fireEvent argument to ReorderColumn since the ColumnReordered event must not be signaled when modifying DisplayIndex of a ColumnHeader. Added internal ReorderColumns method which takes care of drawing, and updating the internal DisplayIndex of the ColumnHeader. Added AddColumn method which is invoked from ColumnHeaderCollection when adding or inserting columns, and which ensures that reorder_columns_indices is kept in sync. Avoid redrawing after adding each ColumnHeader in ColumnHeaderCollection.AddRange. Recalculated dispay indices after removing a ColumnHeader. * ColumnHeader.cs: Save DisplayIndex separately from ListView to match MS. Allows last display index to be returned after ListView is disposed. Update actual location of ColumnHeader when DisplayIndex is modified. * ListViewCollectionsTest.cs: Added ColumnHeader.Index tests. * ColumnHeaderTest.cs: Added more DisplayIndex tests. svn path=/trunk/mcs/; revision=73617 --- .../System.Windows.Forms/ColumnHeader.cs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnHeader.cs') diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnHeader.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnHeader.cs index e4970728d51..b6c3f5c9687 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnHeader.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnHeader.cs @@ -51,6 +51,7 @@ namespace System.Windows.Forms private string name = String.Empty; private object tag; #endif + private int display_index = -1; // internal variables Rectangle column_rect = Rectangle.Empty; @@ -132,8 +133,13 @@ namespace System.Windows.Forms get { return format; } } + internal int InternalDisplayIndex { + get { return display_index; } + set { display_index = value; } + } + internal void CalcColumnHeader () - { + { if (text_alignment == HorizontalAlignment.Center) format.Alignment = StringAlignment.Center; else if (text_alignment == HorizontalAlignment.Right) @@ -167,23 +173,26 @@ namespace System.Windows.Forms #endregion // Private Internal Methods Properties #region Public Instance Properties + #if NET_2_0 [Localizable (true)] [RefreshProperties (RefreshProperties.Repaint)] public int DisplayIndex { get { if (owner == null) - return -1; + return display_index; return owner.GetReorderedColumnIndex (this); - } + } set { - if (owner == null) + if (owner == null) { + display_index = value; return; + } if (value < 0 || value >= owner.Columns.Count) - throw new ArgumentOutOfRangeException ("value"); + throw new ArgumentOutOfRangeException ("DisplayIndex"); - owner.ReorderColumn (this, value); + owner.ReorderColumn (this, value, false); } } -- cgit v1.2.3