本文整理汇总了C#中System.Windows.Forms.TableLayoutPanel.SetCellPosition方法的典型用法代码示例。如果您正苦于以下问题:C# TableLayoutPanel.SetCellPosition方法的具体用法?C# TableLayoutPanel.SetCellPosition怎么用?C# TableLayoutPanel.SetCellPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.TableLayoutPanel
的用法示例。
在下文中一共展示了TableLayoutPanel.SetCellPosition方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawingToolbox
/// <summary>
/// Constructor.
/// </summary>
public DrawingToolbox()
: base()
{
_panel = new TableLayoutPanel();
_panel.AutoSize = true;
_panel.Dock = DockStyle.Top;
this.Controls.Add(_panel);
InitializeComponent();
_panel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50));
_panel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50));
_panel.RowStyles.Add(new RowStyle(SizeType.Percent, 50));
_panel.RowStyles.Add(new RowStyle(SizeType.Percent, 50));
_panel.Controls.Add(_titleLabel);
_panel.SetCellPosition(_titleLabel, new TableLayoutPanelCellPosition(0,0));
_panel.Controls.Add(DrawnigModeEnabled);
_panel.SetCellPosition(DrawnigModeEnabled, new TableLayoutPanelCellPosition(0,1));
_panel.Controls.Add(ClearButton);
_panel.SetCellPosition(ClearButton, new TableLayoutPanelCellPosition(0, 2));
_panel.Controls.Add(ExportImageButton);
_panel.SetCellPosition(ExportImageButton, new TableLayoutPanelCellPosition(1, 2));
Enabled = false;
DrawnigModeEnabled.Enabled = false;
}
示例2: SelectColumnsDialog
public SelectColumnsDialog( DataGridView dgv )
{
dataGridView = dgv;
columnToCheckboxMap = new Map<string, CheckBox>();
this.Name = "SelectColumnsDialog";
this.Text = "Select Columns";
SplitContainer splitContainer = new SplitContainer();
splitContainer.Orientation = Orientation.Horizontal;
splitContainer.Dock = DockStyle.Fill;
this.Controls.Add( splitContainer );
FlowLayoutPanel panel1 = new FlowLayoutPanel();
panel1.FlowDirection = FlowDirection.TopDown;
panel1.Dock = DockStyle.Fill;
splitContainer.Panel1.Controls.Add( panel1 );
foreach( DataGridViewColumn column in dgv.Columns )
{
CheckBox checkbox = new CheckBox();
checkbox.Text = column.HeaderText;
checkbox.Checked = column.Visible;
columnToCheckboxMap.Add( column.Name, checkbox );
panel1.Controls.Add( checkbox );
}
TableLayoutPanel panel2 = new TableLayoutPanel();
panel2.ColumnCount = 2;
panel2.RowCount = 1;
panel2.Dock = DockStyle.Fill;
splitContainer.Panel2.Controls.Add( panel2 );
Button okButton = new Button();
okButton.Text = "OK";
okButton.Click += new EventHandler( okButton_Click );
this.AcceptButton = okButton;
panel2.Controls.Add( okButton );
panel2.SetCellPosition( okButton, new TableLayoutPanelCellPosition(0,0) );
Button cancelButton = new Button();
cancelButton.Text = "Cancel";
cancelButton.Click += new EventHandler( cancelButton_Click );
this.CancelButton = cancelButton;
panel2.Controls.Add( cancelButton );
panel2.SetCellPosition( cancelButton, new TableLayoutPanelCellPosition(1,0) );
splitContainer.FixedPanel = FixedPanel.Panel2;
splitContainer.SplitterDistance = this.Height - okButton.Height * 2;
splitContainer.IsSplitterFixed = true;
}
示例3: ClipingToolbox
/// <summary>
/// Constructor.
/// </summary>
public ClipingToolbox()
: base()
{
_panel = new TableLayoutPanel();
_panel.AutoSize = true;
_panel.Dock = DockStyle.Top;
this.Controls.Add(_panel);
InitializeComponent();
this.Controls.Add(titleLabel);
titleLabel.Dock = DockStyle.Top;
titleLabel.Padding = new Padding(0, 5, 0, 5);
_panel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 16));
_panel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 42));
_panel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 42));
_panel.RowStyles.Add(new RowStyle(SizeType.Percent, 30));
_panel.RowStyles.Add(new RowStyle(SizeType.Percent, 30));
_panel.RowStyles.Add(new RowStyle(SizeType.Percent, 30));
_panel.Controls.Add(xLabel);
_panel.SetCellPosition(xLabel, new TableLayoutPanelCellPosition(0, 0));
xLabel.AutoSize = true;
_panel.Controls.Add(XClipingTrackBar1);
_panel.SetCellPosition(XClipingTrackBar1, new TableLayoutPanelCellPosition(1, 0));
_panel.Controls.Add(XClipingTrackBar2);
_panel.SetCellPosition(XClipingTrackBar2, new TableLayoutPanelCellPosition(2, 0));
_panel.Controls.Add(yLabel);
_panel.SetCellPosition(yLabel, new TableLayoutPanelCellPosition(0, 1));
zLabel.AutoSize = true;
_panel.Controls.Add(YClipingTrackBar1);
_panel.SetCellPosition(YClipingTrackBar1, new TableLayoutPanelCellPosition(1, 1));
_panel.Controls.Add(YClipingTrackBar2);
_panel.SetCellPosition(YClipingTrackBar2, new TableLayoutPanelCellPosition(2, 1));
_panel.Controls.Add(zLabel);
_panel.SetCellPosition(zLabel, new TableLayoutPanelCellPosition(0, 2));
zLabel.AutoSize = true;
_panel.Controls.Add(ZClipingTrackBar1);
_panel.SetCellPosition(ZClipingTrackBar1, new TableLayoutPanelCellPosition(1, 2));
_panel.Controls.Add(ZClipingTrackBar2);
_panel.SetCellPosition(ZClipingTrackBar2, new TableLayoutPanelCellPosition(2, 2));
}
示例4: TestExtenderMethods
public void TestExtenderMethods ()
{
TableLayoutPanel p = new TableLayoutPanel ();
Control c = new Button ();
Assert.AreEqual (new TableLayoutPanelCellPosition (-1, -1), p.GetCellPosition (c), "A1");
Assert.AreEqual (-1, p.GetColumn (c), "A2");
Assert.AreEqual (1, p.GetColumnSpan (c), "A3");
Assert.AreEqual (-1, p.GetRow (c), "A4");
Assert.AreEqual (1, p.GetRowSpan (c), "A5");
p.SetCellPosition (c, new TableLayoutPanelCellPosition (1, 1));
Assert.AreEqual (new TableLayoutPanelCellPosition (1, 1), p.GetCellPosition (c), "A6");
p.SetColumn (c, 2);
Assert.AreEqual (2, p.GetColumn (c), "A7");
p.SetRow (c, 2);
Assert.AreEqual (2, p.GetRow (c), "A9");
p.SetColumnSpan (c, 2);
Assert.AreEqual (2, p.GetColumnSpan (c), "A8");
p.SetRowSpan (c, 2);
Assert.AreEqual (2, p.GetRowSpan (c), "A10");
Assert.AreEqual (new TableLayoutPanelCellPosition (2, 2), p.GetCellPosition (c), "A11");
// ???????
//Assert.AreEqual (new TableLayoutPanelCellPosition (-1, -1), p.GetPositionFromControl (c), "A12");
//Assert.AreEqual (c, p.GetControlFromPosition(0, 0), "A13");
}
示例5: TestCellPositioning18
public void TestCellPositioning18 ()
{
// A control with both rowspan and columnspan > 1 was getting
// other controls put into its extent (i.e. c3 was ending up
// at (1,1) instead of (2,1).
TableLayoutPanel p = new TableLayoutPanel ();
Control c1 = new Button ();
Control c2 = new Button ();
Control c3 = new Button ();
Control c4 = new Button ();
p.ColumnCount = 3;
p.RowCount = 4;
p.SetRowSpan (c1, 2);
p.SetColumnSpan (c1, 2);
p.SetCellPosition (c1, new TableLayoutPanelCellPosition (0, 0));
p.Controls.Add (c1);
p.Controls.Add (c2);
p.Controls.Add (c3);
p.Controls.Add (c4);
Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
Assert.AreEqual (new TableLayoutPanelCellPosition (2, 0), p.GetPositionFromControl (c2), "C2");
Assert.AreEqual (new TableLayoutPanelCellPosition (2, 1), p.GetPositionFromControl (c3), "C3");
Assert.AreEqual (new TableLayoutPanelCellPosition (0, 2), p.GetPositionFromControl (c4), "C4");
}
示例6: TestCellPositioning16
public void TestCellPositioning16 ()
{
// 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 = 2;
p.SetRowSpan (c3, 2);
p.SetCellPosition (c3, new TableLayoutPanelCellPosition (0, 1));
p.Controls.Add (c1);
p.Controls.Add (c2);
p.Controls.Add (c3);
Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c2), "C2");
Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c3), "C3");
}
示例7: TestCellPositioning15
public void TestCellPositioning15 ()
{
// Column span = 2, but control is in the last column, forces control back into 1st column, next row
// I have no clue why c3 shouldn't be in (1,0), but MS says it's not
TableLayoutPanel p = new TableLayoutPanel ();
Control c1 = new Button ();
Control c2 = new Button ();
Control c3 = new Button ();
p.ColumnCount = 2;
p.RowCount = 2;
p.SetColumnSpan (c2, 2);
p.SetCellPosition (c2, new TableLayoutPanelCellPosition (1, 0));
p.Controls.Add (c1);
p.Controls.Add (c2);
p.Controls.Add (c3);
Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c1), "C1");
Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c2), "C2");
Assert.AreEqual (new TableLayoutPanelCellPosition (0, 2), p.GetPositionFromControl (c3), "C3");
}
示例8: TestCellPositioning5
public void TestCellPositioning5 ()
{
// One control have fixed position
TableLayoutPanel p = new TableLayoutPanel ();
Control c1 = new Button ();
Control c2 = new Button ();
Control c3 = new Button ();
Control c4 = new Button ();
p.ColumnCount = 2;
p.RowCount = 2;
p.SetCellPosition (c4, new TableLayoutPanelCellPosition (0, 0));
p.Controls.Add (c1);
p.Controls.Add (c2);
p.Controls.Add (c3);
p.Controls.Add (c4);
Assert.AreEqual (new TableLayoutPanelCellPosition (0, 0), p.GetPositionFromControl (c4), "C1");
Assert.AreEqual (new TableLayoutPanelCellPosition (1, 0), p.GetPositionFromControl (c1), "C2");
Assert.AreEqual (new TableLayoutPanelCellPosition (0, 1), p.GetPositionFromControl (c2), "C3");
Assert.AreEqual (new TableLayoutPanelCellPosition (1, 1), p.GetPositionFromControl (c3), "C4");
}
示例9: InitializeModelUI
private void InitializeModelUI(MeshModel model)
{
this.modelData.Controls.Clear();
var meshes = model.Meshes.ToArray();
for (int i = 0; i < meshes.Length; i++)
{
var mesh = meshes[i];
GroupBox box = new GroupBox()
{
Dock = DockStyle.Top,
Text = "Mesh " + (i.ToString())
};
var table = new TableLayoutPanel()
{
Dock = DockStyle.Fill
};
table.ColumnCount = 2;
table.RowCount = 1;
table.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 0.5f));
table.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 0.5f));
Action<Func<Tuple<string, Control>>> addRow = (func) =>
{
var row = func();
var label = new Label()
{
Dock = DockStyle.Fill,
AutoSize = false,
TextAlign = ContentAlignment.MiddleLeft,
Text = row.Item1
};
table.Controls.Add(label);
table.Controls.Add(row.Item2);
table.SetCellPosition(label, new TableLayoutPanelCellPosition(0, table.RowCount-1));
table.SetCellPosition(row.Item2, new TableLayoutPanelCellPosition(1, table.RowCount - 1));
table.RowStyles.Add(new RowStyle(SizeType.Absolute, 28));
table.RowCount += 1;
};
// Texture Editor
addRow(() =>
{
var editor = new NumericUpDown()
{
Dock = DockStyle.Fill,
Minimum = 0,
Maximum = this.textures.Count - 1,
Value = Math.Min(this.textures.Count - 1, mesh.Texture),
Increment = 1,
};
editor.ValueChanged += (s, e) =>
{
mesh.SetTexture((int)editor.Value);
};
return new Tuple<string, Control>("Texture:", editor);
});
// Scale tool
addRow(() =>
{
var editor = new TextBox()
{
Dock = DockStyle.Fill,
Text = "1.0"
};
var button = new Button()
{
Text = "Scale",
Dock = DockStyle.Right
};
button.Click += (s, e) =>
{
float scale = float.Parse(editor.Text, CultureInfo.InvariantCulture);
for (int j = 0; j < mesh.Vertices.Length; j++)
{
mesh.Vertices[j].position *= scale;
}
mesh.Update();
};
var panel = new Panel()
{
Dock = DockStyle.Fill,
Height = 24
};
panel.Controls.Add(editor);
panel.Controls.Add(button);
return new Tuple<string, Control>("Scale:", panel);
});
// Translate tool
//.........这里部分代码省略.........
示例10: setTableLayout
private void setTableLayout(TableLayoutPanel t)
{
// tableLayoutPanel1.SuspendLayout();
t.Controls.Clear();
int _rowNum = t.RowCount;
int _colNum = t.ColumnCount;
t.Dock = DockStyle.Fill;
//int _height = t.Height;
int _width = t.Width;
int _cellHeight = 20;//高度固定
int _cellWidth = _width / _colNum;
for (int i = 0; i < _rowNum; i++)
{
t.RowStyles[i].SizeType = SizeType.Absolute;
t.RowStyles[i].Height = _cellHeight;
}
for (int j = 0; j < _colNum; j++)
{
t.ColumnStyles[j].SizeType = SizeType.Absolute;
t.ColumnStyles[j].Width = _cellWidth;
}
for (int i = 0; i < _rowNum; i++)
{
for (int j = 0; j < _colNum; j++)
{
//if (i == 0 && j == 0) break;
TextBox tBox= new TextBox();//一定要在这里new一下,不然就是未引用对象到实例
t.Controls.Add(tBox);
tBox.Text = i.ToString() + ":" + j.ToString();
tBox.Name = "tBox" + i.ToString() + "_" + j.ToString();
TableLayoutPanelCellPosition p = new TableLayoutPanelCellPosition(j, i);
t.SetCellPosition(tBox, p);
}
}
t.Height = _cellHeight * _rowNum;
//tableLayoutPanel1.ResumeLayout();
}
示例11: RemoveRow
void RemoveRow(int row, TableLayoutPanel targetPanel)
{
if (row == targetPanel.RowCount - 1)
return;
targetPanel.SuspendLayout();
for (int i = 0; i < targetPanel.ColumnCount; i++)
targetPanel.Controls.Remove(targetPanel.GetControlFromPosition(i, row));
for (int r = row + 1; r < targetPanel.RowCount; r++)
for (int c = 0; c < targetPanel.ColumnCount; c++)
if(targetPanel.GetControlFromPosition(c, r) != null)
targetPanel.SetCellPosition(targetPanel.GetControlFromPosition(c, r) , new TableLayoutPanelCellPosition(c, r - 1));
targetPanel.RowCount--;
//Re-layout label numbers
LayoutNumber(targetPanel);
targetPanel.ResumeLayout();
}
示例12: MoveRow
void MoveRow(int row, int offset, TableLayoutPanel targetPanel)
{
if (row + offset <= 0 || row + offset >= targetPanel.RowCount - 1)
return;
targetPanel.SuspendLayout();
for (int i = 0; i < targetPanel.ColumnCount - 1; i++)
{
Control currentControl = targetPanel.GetControlFromPosition(i, row);
Control offsetControl = targetPanel.GetControlFromPosition(i, row + offset);
targetPanel.SetCellPosition(currentControl, new TableLayoutPanelCellPosition(i, row + offset));
targetPanel.SetCellPosition(offsetControl, new TableLayoutPanelCellPosition(i, row));
}
//Re-layout label numbers
LayoutNumber(targetPanel);
targetPanel.ResumeLayout();
}
示例13: SetControl
public static void SetControl(TableLayoutPanel tlp,Control ctrl,int c,int r)
{
tlp.Controls.Add(ctrl);
tlp.SetCellPosition(ctrl, new TableLayoutPanelCellPosition(c, r));
}