View | Details | Raw Unified | Return to bug 2394
Collapse All | Expand All

(-)a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridView.cs (-25 / +18 lines)
Lines 3129-3134 namespace System.Windows.Forms { Link Here
3129
				InvalidateRow (i);
3129
				InvalidateRow (i);
3130
		}
3130
		}
3131
3131
3132
		private void UpdateRowHeightInfo (DataGridViewRow row)
3133
		{
3134
			DataGridViewRowHeightInfoNeededEventArgs rowInfo =
3135
				new DataGridViewRowHeightInfoNeededEventArgs (row.Index, row.Height, row.MinimumHeight);
3136
			OnRowHeightInfoNeeded (rowInfo);
3137
3138
			if (row.Height != rowInfo.Height || row.MinimumHeight != rowInfo.MinimumHeight) {
3139
				row.MinimumHeight = rowInfo.MinimumHeight;
3140
				row.Height = rowInfo.Height;
3141
				OnRowHeightInfoPushed (new DataGridViewRowHeightInfoPushedEventArgs (row.Index, rowInfo.Height,
3142
													rowInfo.MinimumHeight));
3143
			}
3144
		}
3145
3132
		public void UpdateRowHeightInfo (int rowIndex, bool updateToEnd)
3146
		public void UpdateRowHeightInfo (int rowIndex, bool updateToEnd)
3133
		{
3147
		{
3134
			if (rowIndex < 0 && updateToEnd)
3148
			if (rowIndex < 0 && updateToEnd)
Lines 3148-3180 namespace System.Windows.Forms { Link Here
3148
3162
3149
			if (updateToEnd) {
3163
			if (updateToEnd) {
3150
				for (int i = rowIndex; i < Rows.Count; i++) {
3164
				for (int i = rowIndex; i < Rows.Count; i++) {
3151
					DataGridViewRow row = Rows[i];
3165
					DataGridViewRow row = Rows [i];
3152
					if (!row.Visible)
3166
					if (row.Visible)
3153
						continue;
3167
						UpdateRowHeightInfo (row);
3154
3155
					DataGridViewRowHeightInfoNeededEventArgs rowInfo = 
3156
						new DataGridViewRowHeightInfoNeededEventArgs (row.Index, row.Height, row.MinimumHeight);
3157
					OnRowHeightInfoNeeded (rowInfo);
3158
3159
					if (row.Height != rowInfo.Height || row.MinimumHeight != rowInfo.MinimumHeight) {
3160
						row.Height = rowInfo.Height;
3161
						row.MinimumHeight = rowInfo.MinimumHeight;
3162
						OnRowHeightInfoPushed (new DataGridViewRowHeightInfoPushedEventArgs (row.Index, rowInfo.Height, 
3163
														     rowInfo.MinimumHeight));
3164
					}
3165
				}
3168
				}
3166
			} else {
3169
			} else {
3167
				DataGridViewRow row = Rows[rowIndex];
3170
				UpdateRowHeightInfo (Rows [rowIndex]);
3168
				DataGridViewRowHeightInfoNeededEventArgs rowInfo = 
3169
					new DataGridViewRowHeightInfoNeededEventArgs (row.Index, row.Height, row.MinimumHeight);
3170
				OnRowHeightInfoNeeded (rowInfo);
3171
3172
				if (row.Height != rowInfo.Height || row.MinimumHeight != rowInfo.MinimumHeight) {
3173
					row.Height = rowInfo.Height;
3174
					row.MinimumHeight = rowInfo.MinimumHeight;
3175
					OnRowHeightInfoPushed (new DataGridViewRowHeightInfoPushedEventArgs (row.Index, rowInfo.Height, 
3176
													     rowInfo.MinimumHeight));
3177
				}
3178
			}
3171
			}
3179
		}
3172
		}
3180
3173
(-)a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewTest.cs (-1 / +54 lines)
Lines 1842-1847 namespace MonoTests.System.Windows.Forms Link Here
1842
				Assert.AreEqual (30, dgv.Rows [1].MinimumHeight);
1842
				Assert.AreEqual (30, dgv.Rows [1].MinimumHeight);
1843
			}
1843
			}
1844
		}
1844
		}
1845
1846
		[Test]
1847
		public void RowHeightLessThanOldMinHeightVirtMode ()
1848
		{
1849
			using (var dgv = new DataGridView ()) {
1850
				dgv.VirtualMode = true;
1851
				dgv.RowCount = 1;
1852
				dgv.Rows [0].Height = 10;
1853
				dgv.Rows [0].MinimumHeight = 5;
1854
				dgv.RowHeightInfoNeeded += (sender, e) => {
1855
					e.Height = 2;
1856
					e.MinimumHeight = 2;
1857
				};
1858
				dgv.UpdateRowHeightInfo (0, false);
1859
				Assert.AreEqual (2, dgv.Rows [0].Height);
1860
				Assert.AreEqual (2, dgv.Rows [0].MinimumHeight);
1861
			}
1862
		}
1863
1864
		[Test]
1865
		[ExpectedException (typeof (ArgumentOutOfRangeException))]
1866
		public void RowHeightLessThanMinHeightVirtMode ()
1867
		{
1868
			using (var dgv = new DataGridView ()) {
1869
				dgv.VirtualMode = true;
1870
				dgv.RowCount = 1;
1871
				dgv.Rows [0].Height = 10;
1872
				dgv.Rows [0].MinimumHeight = 5;
1873
				dgv.RowHeightInfoNeeded += (sender, e) => {
1874
					e.Height = 2;
1875
					e.MinimumHeight = 5;
1876
				};
1877
				// we expect an exception on the next line
1878
				dgv.UpdateRowHeightInfo (0, false);
1879
			}
1880
		}
1881
1882
		[Test]
1883
		public void MinHeightGreaterThanOldRowHeightVirtMode ()
1884
		{
1885
			using (var dgv = new DataGridView ()) {
1886
				dgv.VirtualMode = true;
1887
				dgv.RowCount = 1;
1888
				dgv.Rows [0].Height = 10;
1889
				dgv.Rows [0].MinimumHeight = 5;
1890
				dgv.RowHeightInfoNeeded += (sender, e) => {
1891
					e.MinimumHeight = 30;
1892
					e.Height = 40;
1893
				};
1894
				dgv.UpdateRowHeightInfo (0, false);
1895
				Assert.AreEqual (40, dgv.Rows [0].Height);
1896
				Assert.AreEqual (30, dgv.Rows [0].MinimumHeight);
1897
			}
1898
		}
1845
	}
1899
	}
1846
	
1900
	
1847
	[TestFixture]
1901
	[TestFixture]
1848
- 

Return to bug 2394