本文整理汇总了C#中System.Windows.Forms.TableLayoutPanel.GetRowHeights方法的典型用法代码示例。如果您正苦于以下问题:C# TableLayoutPanel.GetRowHeights方法的具体用法?C# TableLayoutPanel.GetRowHeights怎么用?C# TableLayoutPanel.GetRowHeights使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.TableLayoutPanel
的用法示例。
在下文中一共展示了TableLayoutPanel.GetRowHeights方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestRowColumnSizes11
public void TestRowColumnSizes11 ()
{
// AutoSize Columns/Rows, and column-spanning controls, but
// no control starts in column 1.
// Mono's old behavior was for column 1 to have a zero width.
TableLayoutPanel p = new TableLayoutPanel ();
Control c1 = new Button ();
Control c2 = new Button ();
Control c3 = new Button ();
c1.Size = new Size (150, 25);
c2.Size = new Size (75, 25);
c3.Size = new Size (150, 25);
p.ColumnCount = 4;
p.RowCount = 3;
p.RowStyles.Add (new RowStyle (SizeType.AutoSize));
p.RowStyles.Add (new RowStyle (SizeType.AutoSize));
p.RowStyles.Add (new RowStyle (SizeType.AutoSize));
p.ColumnStyles.Add (new ColumnStyle (SizeType.AutoSize));
p.ColumnStyles.Add (new ColumnStyle (SizeType.AutoSize));
p.ColumnStyles.Add (new ColumnStyle (SizeType.AutoSize));
p.ColumnStyles.Add (new ColumnStyle (SizeType.AutoSize));
p.SetColumnSpan (c1, 2);
p.SetColumnSpan (c3, 2);
p.Controls.Add (c1, 0, 0);
p.Controls.Add (c2, 0, 1);
p.Controls.Add (c3, 1, 1);
// The bug fix gets Mono to behave very closely to .NET,
// but not exactly...3 pixels off somewhere...
Assert.AreEqual (31, p.GetRowHeights ()[0], "D1");
Assert.AreEqual (31, p.GetRowHeights ()[1], "D2");
Assert.AreEqual (81, p.GetColumnWidths ()[0], "D3");
Assert.LessOrEqual (75, p.GetColumnWidths ()[1], "D4");
Assert.GreaterOrEqual (78, p.GetColumnWidths ()[1], "D5");
Assert.LessOrEqual (78, p.GetColumnWidths ()[2], "D6");
Assert.GreaterOrEqual (81, p.GetColumnWidths ()[2], "D7");
}
示例2: TestRowColumnSizes9
public void TestRowColumnSizes9 ()
{
// 1 Absolute and 2 Percent Columns/Rows (with total percents > 100)
TableLayoutPanel p = new TableLayoutPanel ();
Control c1 = new Button ();
Control c2 = new Button ();
Control c3 = new Button ();
p.ColumnCount = 3;
p.RowCount = 3;
p.RowStyles.Add (new RowStyle (SizeType.Absolute, 50));
p.RowStyles.Add (new RowStyle (SizeType.Percent, 80));
p.RowStyles.Add (new RowStyle (SizeType.Percent, 40));
p.ColumnStyles.Add (new ColumnStyle (SizeType.Absolute, 50));
p.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 80));
p.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 40));
p.Controls.Add (c1);
p.Controls.Add (c2);
p.Controls.Add (c3);
Assert.AreEqual (50, p.GetRowHeights ()[0], "D1");
Assert.AreEqual (33, p.GetRowHeights ()[1], "D2");
Assert.AreEqual (17, p.GetRowHeights ()[2], "D3");
Assert.AreEqual (50, p.GetColumnWidths ()[0], "D4");
Assert.AreEqual (100, p.GetColumnWidths ()[1], "D5");
Assert.AreEqual (50, p.GetColumnWidths ()[2], "D6");
}
示例3: TestRowColumnSizes10
public void TestRowColumnSizes10 ()
{
// 2 AutoSize Columns/Rows
TableLayoutPanel p = new TableLayoutPanel ();
Control c1 = new Button ();
Control c2 = new Button ();
Control c3 = new Button ();
p.ColumnCount = 2;
p.RowCount = 2;
p.RowStyles.Add (new RowStyle (SizeType.AutoSize));
p.RowStyles.Add (new RowStyle (SizeType.AutoSize));
p.ColumnStyles.Add (new ColumnStyle (SizeType.AutoSize));
p.ColumnStyles.Add (new ColumnStyle (SizeType.AutoSize));
p.Controls.Add (c1);
p.Controls.Add (c2);
p.Controls.Add (c3);
Assert.AreEqual (29, p.GetRowHeights ()[0], "D1");
Assert.AreEqual (71, p.GetRowHeights ()[1], "D2");
Assert.AreEqual (81, p.GetColumnWidths ()[0], "D3");
Assert.AreEqual (119, p.GetColumnWidths ()[1], "D4");
}
示例4: TestRowColumnSizes6
public void TestRowColumnSizes6 ()
{
// 2 50% Columns/Rows
TableLayoutPanel p = new TableLayoutPanel ();
Control c1 = new Button ();
Control c2 = new Button ();
Control c3 = new Button ();
p.ColumnCount = 2;
p.RowCount = 2;
p.RowStyles.Add (new RowStyle (SizeType.Percent, 50));
p.RowStyles.Add (new RowStyle (SizeType.Percent, 50));
p.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 50));
p.ColumnStyles.Add (new ColumnStyle (SizeType.Percent, 50));
p.Controls.Add (c1);
p.Controls.Add (c2);
p.Controls.Add (c3);
Assert.AreEqual (50, p.GetRowHeights ()[0], "D1");
Assert.AreEqual (50, p.GetRowHeights ()[1], "D2");
Assert.AreEqual (100, p.GetColumnWidths ()[0], "D3");
Assert.AreEqual (100, p.GetColumnWidths ()[1], "D4");
}
示例5: TestRowColumnSizes4
public void TestRowColumnSizes4 ()
{
// Row span = 2, but control is in the last row, creates new row
TableLayoutPanel p = new TableLayoutPanel ();
Control c1 = new Button ();
Control c2 = new Button ();
Control c3 = new Button ();
Control c4 = new Button ();
Control c5 = new Button ();
Control c6 = new Button ();
Control c7 = new Button ();
p.ColumnCount = 2;
p.RowCount = 1;
p.RowStyles.Add (new RowStyle (SizeType.Percent, 100F));
p.Controls.Add (c1);
p.Controls.Add (c2);
p.Controls.Add (c3);
p.Controls.Add (c4);
p.Controls.Add (c5);
p.Controls.Add (c6);
p.Controls.Add (c7);
//Assert.AreEqual (100, p.GetRowHeights ()[0], "D1");
Assert.AreEqual (29, p.GetRowHeights ()[1], "D2");
Assert.AreEqual (29, p.GetRowHeights ()[2], "D3");
Assert.AreEqual (29, p.GetRowHeights ()[3], "D4");
}
示例6: TestRowColumnSizes2
public void TestRowColumnSizes2 ()
{
// Row span = 2, but control is in the last row, creates new row
TableLayoutPanel p = new TableLayoutPanel ();
Control c1 = new Button ();
Control c2 = new Button ();
Control c3 = new Button ();
p.ColumnCount = 2;
p.RowCount = 1;
p.RowStyles.Add (new RowStyle (SizeType.Absolute, 100F));
p.Controls.Add (c1);
p.Controls.Add (c2);
p.Controls.Add (c3);
Assert.AreEqual (100, p.GetRowHeights ()[0], "D1");
Assert.AreEqual (29, p.GetRowHeights ()[1], "D2");
}
示例7: PopulateContainerBox
//.........这里部分代码省略.........
breadCrumbs_ListChanged(null, null);
}
};
crumbTable.Controls.Add(deleteLink, 2, x);
if (deleteLink.Width > 0)
lastColumnSize = deleteLink.Width;
}
//if there exists more than one page add navigation row
if (containerBook.Count > 1)
{
//forward and back buttons
if (pageIndex > 0)
{
var backButton = new Button { Text = "<-", Size = new Size(30, 20) };
backButton.Click += (x, y) =>
{
PopulateContainerBox(dataFilter, containerBook, pageIndex - 1,
crumbTable, crumb);
if (_subItemPopup != null)
_subItemPopup.Size = _tableSize;
};
crumbTable.Controls.Add(backButton, 0, dataSet.Count);
if (backButton.Width > firstColumnSize)
firstColumnSize = backButton.Width;
}
if (pageIndex < containerBook.Count - 1)
{
var forwardButton = new Button { Text = "->", Size = new Size(30, 20) };
forwardButton.Click += (x, y) =>
{
PopulateContainerBox(dataFilter, containerBook, pageIndex + 1,
crumbTable, crumb);
if (_subItemPopup != null)
_subItemPopup.Size = _tableSize;
};
crumbTable.Controls.Add(forwardButton, 2, dataSet.Count);
if (forwardButton.Width > lastColumnSize)
lastColumnSize = forwardButton.Width;
}
//middle page reporting / goto page control
var cellPanel = new Panel {Size = new Size(largestDescription, 23)};
var pageLabel = new Label {Text = "Page ", AutoSize = true};
pageLabel.Font = new Font(pageLabel.Font.ToString(),10.0f);
var pageSelectBox = new TextBox {Text = (pageIndex + 1).ToString(), TextAlign = HorizontalAlignment.Center};
pageSelectBox.KeyPress += (x, y) =>
{
//if enter is pressed go to selected page (or reset to current page if no valid page is selected)
if (y.KeyChar == (char)13)
{
y.Handled = true;
int tempInt;
if (!int.TryParse(pageSelectBox.Text, out tempInt) ||
tempInt <= 0 || tempInt > containerBook.Count)
pageSelectBox.Text = (pageIndex + 1).ToString();
else
{
PopulateContainerBox(dataFilter, containerBook, tempInt - 1,
crumbTable, crumb);
if (_subItemPopup != null)
_subItemPopup.Size = _tableSize;
}
}
};
pageSelectBox.Leave += (x, y) => { pageSelectBox.Text = (pageIndex + 1).ToString(); };
var totalLabel = new Label { Text = " of " + containerBook.Count, AutoSize = true };
totalLabel.Font = new Font(totalLabel.Font.ToString(), 10.0f);
//add all three controls to the cell panel
cellPanel.Controls.Add(pageLabel);
cellPanel.Controls.Add(pageSelectBox);
cellPanel.Controls.Add(totalLabel);
//make sure boxes are wide enough
pageSelectBox.Width = totalLabel.Width-10;
var totalCellWidth = pageLabel.Width + pageSelectBox.Width + totalLabel.Width;
if (totalCellWidth > largestDescription)
{
largestDescription = totalCellWidth;
cellPanel.Width = totalCellWidth;
}
//reposition controls to final locations
var startlocation = (largestDescription - totalCellWidth) / 2;
pageLabel.Location = new Point(startlocation, 0);
pageSelectBox.Location = new Point(startlocation + pageLabel.Width, 0);
totalLabel.Location = new Point(startlocation+pageLabel.Width + pageSelectBox.Width,0);
crumbTable.Controls.Add(cellPanel, 1, dataSet.Count);
}
//Hack: sadly the obvious .GetRowHeights() and .getColumnWidths
//dont give consistantly valid results, as such proper dimentions have
//to be calculated as the table is formed.
var rowHeights = (crumbTable.GetRowHeights().Length) * 24;
var columnWidths = firstColumnSize + lastColumnSize + 25 +largestDescription;
_tableSize = new Size(columnWidths +5, rowHeights +5);
}
示例8: GetRowColIndex
Point? GetRowColIndex(TableLayoutPanel tlp, Point point)
{
if (point.X > tlp.Width || point.Y > tlp.Height)
return null;
int w = tlp.Width;
int h = tlp.Height;
int[] widths = tlp.GetColumnWidths();
int i;
for (i = widths.Length - 1; i >= 0 && point.X < w; i--)
w -= widths[i];
int col = i + 1;
int[] heights = tlp.GetRowHeights();
for (i = heights.Length - 1; i >= 0 && point.Y < h; i--)
h -= heights[i];
int row = i + 1;
return new Point(col, row);
}