1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2007 Novell, Inc. (http://www.novell.com)
23 // Rolf Bjarne Kvinge (RKvinge@novell.com)
28 using NUnit.Framework;
31 using System.Windows.Forms;
32 using System.ComponentModel;
33 using System.Collections;
35 namespace MonoTests.System.Windows.Forms
39 public class DataGridViewColumnCollectionTest
42 [ExpectedException (typeof (InvalidOperationException), "Column's SortMode cannot be set to Automatic while the DataGridView control's SelectionMode is set to FullColumnSelect.")]
43 public void AddFullColumnSelect ()
45 DataGridView dgv = new DataGridView ();
46 dgv.SelectionMode = DataGridViewSelectionMode.FullColumnSelect;
47 dgv.Columns.Add ("A", "A");
53 DataGridViewColumnCollection c;
55 c = new DataGridViewColumnCollection (DataGridViewCommon.CreateAndFill ());
58 DataGridViewColumn col = c [0];
60 Assert.AreEqual ("DataGridViewTextBoxColumn { Name=A, Index=0 }", col.ToString (), "T3");
61 Assert.AreEqual ("DataGridViewTextBoxColumn", col.GetType ().Name, "G2");
63 Assert.AreEqual (DataGridViewAutoSizeColumnMode.NotSet, col.AutoSizeMode, "#A col.AutoSizeMode");
64 Assert.IsNotNull (col.CellTemplate, "#A col.CellTemplate");
65 Assert.IsNotNull (col.CellType, "#A col.CellType");
66 Assert.IsNull (col.ContextMenuStrip, "#A col.ContextMenuStrip");
67 Assert.IsNotNull (col.DataGridView, "#A col.DataGridView");
68 Assert.AreEqual (@"", col.DataPropertyName, "#A col.DataPropertyName");
69 Assert.IsNotNull (col.DefaultCellStyle, "#A col.DefaultCellStyle");
70 Assert.IsNotNull (col.DefaultHeaderCellType, "#A col.DefaultHeaderCellType");
71 Assert.AreEqual (false, col.Displayed, "#A col.Displayed");
72 Assert.AreEqual (0, col.DisplayIndex, "#A col.DisplayIndex");
73 Assert.AreEqual (0, col.DividerWidth, "#A col.DividerWidth");
74 Assert.AreEqual (100, col.FillWeight, "#A col.FillWeight");
75 Assert.AreEqual (false, col.Frozen, "#A col.Frozen");
76 Assert.AreEqual (true, col.HasDefaultCellStyle, "#A col.HasDefaultCellStyle");
77 Assert.IsNotNull (col.HeaderCell, "#A col.HeaderCell");
78 Assert.AreEqual (@"B", col.HeaderText, "#A col.HeaderText");
79 Assert.AreEqual (0, col.Index, "#A col.Index");
80 Assert.AreEqual (DataGridViewAutoSizeColumnMode.None, col.InheritedAutoSizeMode, "#A col.InheritedAutoSizeMode");
81 Assert.IsNotNull (col.InheritedStyle, "#A col.InheritedStyle");
82 Assert.AreEqual (false, col.IsDataBound, "#A col.IsDataBound");
83 Assert.AreEqual (5, col.MinimumWidth, "#A col.MinimumWidth");
84 Assert.AreEqual (@"A", col.Name, "#A col.Name");
85 Assert.AreEqual (false, col.ReadOnly, "#A col.ReadOnly");
86 Assert.AreEqual (DataGridViewTriState.True, col.Resizable, "#A col.Resizable");
87 Assert.AreEqual (false, col.Selected, "#A col.Selected");
88 Assert.IsNull (col.Site, "#A col.Site");
89 Assert.AreEqual (DataGridViewColumnSortMode.Automatic, col.SortMode, "#A col.SortMode");
90 Assert.AreEqual (DataGridViewElementStates.Visible, col.State, "#A col.State");
91 Assert.IsNull (col.Tag, "#A col.Tag");
92 Assert.AreEqual (@"", col.ToolTipText, "#A col.ToolTipText");
93 Assert.IsNull (col.ValueType, "#A col.ValueType");
94 Assert.AreEqual (true, col.Visible, "#A col.Visible");
95 Assert.AreEqual (100, col.Width, "#A col.Width");