public void ThreeRowsWithWeightAndFixedRow() { using (DummySplitGrid grid = new DummySplitGrid(3, 3)) { grid.Size = new Size(122, 122); grid.CreateControl(); grid.AddControl(null, 0, 0, null); grid.AddControl(null, 1, 0, null); grid.AddControl(null, 2, 0, null); grid.Columns[0].Visible = true; grid.Rows[0].Visible = true; grid.Rows[1].Visible = true; grid.Rows[2].Visible = true; grid.GetRow(0).Height = 20; grid.GetRow(0).IsAutoFill = false; grid.GetRow(1).FillWeight = 100; grid.GetRow(2).FillWeight = 17; grid.CallOnShown(); // First row should have fixed height of 20 Assert.AreEqual(20, grid.Rows[0].Height); // Rows should occupy 85%/15% of the available height. Assert.AreEqual(85, grid.Rows[1].Height); Assert.AreEqual(15, grid.Rows[2].Height); } }
public void RowHeightDistributedEvenly() { using (DummySplitGrid grid = new DummySplitGrid(3, 3)) { grid.Size = new Size(100, 100); grid.CreateControl(); grid.AddControl(null, 0, 0, null); grid.AddControl(null, 0, 1, null); grid.AddControl(null, 0, 2, null); grid.AddControl(null, 1, 0, null); grid.AddControl(null, 1, 1, null); grid.AddControl(null, 1, 2, null); grid.AddControl(null, 2, 0, null); grid.AddControl(null, 2, 1, null); grid.AddControl(null, 2, 2, null); foreach (DataGridViewColumn column in grid.Columns) { column.Visible = true; } foreach (DataGridViewRow row in grid.Rows) { row.Visible = true; } grid.CallOnShown(); // Grid height is 100 with 3 rows (i.e. 2 splitters). With a 1px border this leaves 98. Assert.AreEqual(32, grid.Rows[0].Height); Assert.AreEqual(32, grid.Rows[1].Height); Assert.AreEqual(34, grid.Rows[2].Height); } }
public void OneVisibleRowGetsAll() { using (DummySplitGrid grid = new DummySplitGrid(3, 3)) { grid.Size = new Size(100, 100); grid.CreateControl(); grid.AddControl(null, 0, 0, null); grid.AddControl(null, 0, 1, null); grid.AddControl(null, 0, 2, null); grid.AddControl(null, 1, 0, null); grid.AddControl(null, 1, 1, null); grid.AddControl(null, 1, 2, null); grid.AddControl(null, 2, 0, null); grid.AddControl(null, 2, 1, null); grid.AddControl(null, 2, 2, null); foreach (DataGridViewColumn column in grid.Columns) { column.Visible = true; } grid.Rows[1].Visible = true; grid.CallOnShown(); Assert.AreEqual(100, grid.Rows[1].Height); } }
public void ChangingHeightChangesWeight() { DummySplitGrid grid = new DummySplitGrid(3, 1); grid.Size = new Size(102, 102); grid.CreateControl(); grid.AddControl(null, 0, 0, null); grid.AddControl(null, 1, 0, null); grid.AddControl(null, 2, 0, null); grid.Columns[0].Visible = true; grid.Rows[0].Visible = true; grid.Rows[1].Visible = true; grid.Rows[2].Visible = true; grid.GetRow(0).FillWeight = 100; grid.GetRow(1).FillWeight = 200; grid.GetRow(2).FillWeight = 100; grid.CallOnShown(); // first and third row occupy 25% each Assert.AreEqual(25, grid.Rows[0].Height); Assert.AreEqual(25, grid.Rows[2].Height); // second row occupies 50%. Assert.AreEqual(50, grid.Rows[1].Height); // Now change the height of the first row to occupy 50% grid.Rows[0].Height = 50; Assert.AreEqual(50, grid.Rows[0].Height); // second now occupies 2/3 of the remaining 50%, i.e. 33% total Assert.AreEqual(33, grid.Rows[1].Height); // third row occupies the rest (1/3 of the remaining 50%) Assert.AreEqual(17, grid.Rows[2].Height); }
public void TwoRowsWithWeight() { DummySplitGrid grid = new DummySplitGrid(3, 3); grid.Size = new Size(101, 101); grid.CreateControl(); grid.AddControl(null, 0, 0, null); grid.AddControl(null, 1, 0, null); grid.AddControl(null, 2, 0, null); grid.Columns[0].Visible = true; grid.Rows[0].Visible = true; grid.Rows[1].Visible = true; grid.Rows[2].Visible = false; grid.GetRow(0).FillWeight = 100; grid.GetRow(1).FillWeight = 17; grid.CallOnShown(); // Rows should occupy 85%/15% of the available height. Assert.AreEqual(85, grid.Rows[0].Height); Assert.AreEqual(15, grid.Rows[1].Height); }
public void ChangingHeightChangesWeight() { using (DummySplitGrid grid = new DummySplitGrid(3, 1)) { grid.Size = new Size(102, 102); grid.CreateControl(); grid.AddControl(null, 0, 0, null); grid.AddControl(null, 1, 0, null); grid.AddControl(null, 2, 0, null); grid.Columns[0].Visible = true; grid.Rows[0].Visible = true; grid.Rows[1].Visible = true; grid.Rows[2].Visible = true; grid.GetRow(0).FillWeight = 100; grid.GetRow(1).FillWeight = 200; grid.GetRow(2).FillWeight = 100; grid.CallOnShown(); // first and third row occupy 25% each Assert.AreEqual(25, grid.Rows[0].Height); Assert.AreEqual(25, grid.Rows[2].Height); // second row occupies 50%. Assert.AreEqual(50, grid.Rows[1].Height); // Now change the height of the first row to occupy 50% grid.Rows[0].Height = 50; Assert.AreEqual(50, grid.Rows[0].Height); // second now occupies 2/3 of the remaining 50%, i.e. 33% total Assert.AreEqual(33, grid.Rows[1].Height); // third row occupies the rest (1/3 of the remaining 50%) Assert.AreEqual(17, grid.Rows[2].Height); } }
public void TwoRowsWithWeight() { using (DummySplitGrid grid = new DummySplitGrid(3, 3)) { grid.Size = new Size(101, 101); grid.CreateControl(); grid.AddControl(null, 0, 0, null); grid.AddControl(null, 1, 0, null); grid.AddControl(null, 2, 0, null); grid.Columns[0].Visible = true; grid.Rows[0].Visible = true; grid.Rows[1].Visible = true; grid.Rows[2].Visible = false; grid.GetRow(0).FillWeight = 100; grid.GetRow(1).FillWeight = 17; grid.CallOnShown(); // Rows should occupy 85%/15% of the available height. Assert.AreEqual(85, grid.Rows[0].Height); Assert.AreEqual(15, grid.Rows[1].Height); } }
public void OneVisibleRowGetsAll() { using (DummySplitGrid grid = new DummySplitGrid(3, 3)) { grid.Size = new Size(100, 100); grid.CreateControl(); grid.AddControl(null, 0, 0, null); grid.AddControl(null, 0, 1, null); grid.AddControl(null, 0, 2, null); grid.AddControl(null, 1, 0, null); grid.AddControl(null, 1, 1, null); grid.AddControl(null, 1, 2, null); grid.AddControl(null, 2, 0, null); grid.AddControl(null, 2, 1, null); grid.AddControl(null, 2, 2, null); foreach (DataGridViewColumn column in grid.Columns) column.Visible = true; grid.Rows[1].Visible = true; grid.CallOnShown(); Assert.AreEqual(100, grid.Rows[1].Height); } }
public void RowHeightDistributedEvenly() { using (DummySplitGrid grid = new DummySplitGrid(3, 3)) { grid.Size = new Size(100, 100); grid.CreateControl(); grid.AddControl(null, 0, 0, null); grid.AddControl(null, 0, 1, null); grid.AddControl(null, 0, 2, null); grid.AddControl(null, 1, 0, null); grid.AddControl(null, 1, 1, null); grid.AddControl(null, 1, 2, null); grid.AddControl(null, 2, 0, null); grid.AddControl(null, 2, 1, null); grid.AddControl(null, 2, 2, null); foreach (DataGridViewColumn column in grid.Columns) column.Visible = true; foreach (DataGridViewRow row in grid.Rows) row.Visible = true; grid.CallOnShown(); // Grid height is 100 with 3 rows (i.e. 2 splitters). With a 1px border this leaves 98. Assert.AreEqual(32, grid.Rows[0].Height); Assert.AreEqual(32, grid.Rows[1].Height); Assert.AreEqual(34, grid.Rows[2].Height); } }