本文整理汇总了C#中System.Windows.Forms.TableLayoutPanel.Show方法的典型用法代码示例。如果您正苦于以下问题:C# TableLayoutPanel.Show方法的具体用法?C# TableLayoutPanel.Show怎么用?C# TableLayoutPanel.Show使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.TableLayoutPanel
的用法示例。
在下文中一共展示了TableLayoutPanel.Show方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ScheduleForm
int oldTextSize = 0; //Hold measure of text in textbox, resize purposes
#endregion Fields
#region Constructors
//Form layout
public ScheduleForm()
{
allEmployees = EmployeeDatabase.GetAllEmployees();
#region table layout calculations
TableLayoutPanel table = new TableLayoutPanel();
table.SuspendLayout();
table.Location = new Point(40, 140);
table.Size = new Size(800, 300);
table.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single;
//Creating cells - TextBoxes
TOTAL_ROWS = EmployeeDatabase.GetTotalEmployees(); //Get total number of employees - rows
for (int i = 0; i < TOTAL_ROWS; i++)
{
table.RowStyles.Add(new RowStyle(SizeType.Percent, 50.0f));
for (int j = 0; j < TOTAL_COLS + 1; j++)
{
table.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50.0f));
table.Controls.Add(new TextBox() {
Dock = DockStyle.Fill,
Anchor = AnchorStyles.Top | AnchorStyles.Left,
Font = new Font("Arial", 12, FontStyle.Regular),
Name = string.Format("{0},{1}", j, i)
},
j, i);
//Setting specific textboxes
Control c = table.GetControlFromPosition(j, i);
if (j == 0)
{
if (i > 0 && allEmployees[i] != null)
{
c.Text = allEmployees[i].FirstName + " " + allEmployees[i].LastName;
//Change column width only if text is greater that last greater text
int newTextSize = TextRenderer.MeasureText(c.Text, c.Font).Width - 70;
if (newTextSize > oldTextSize)
{
table.ColumnStyles[0].Width = newTextSize;
oldTextSize = newTextSize;
}
}
else
c.Text = "Employee";
}
else if(j > 0 && i == 0) //Days Labels
{
c.Text = (Day)(j - 1) + "";
}
}
}
table.ResumeLayout();
table.Show();
this.Controls.Add(table);
#endregion
#region Print linklabel control
LinkLabel printPage = new LinkLabel();
printPage.Text = "Print";
printPage.Font = new Font("Arial", 10, FontStyle.Regular);
printPage.Location = new Point(table.Bounds.Right - 50, 20);
printPage.Bounds = new Rectangle(printPage.Location,
new Size(50, 20));
//Assign event print
printPage.LinkClicked += new LinkLabelLinkClickedEventHandler(lnkPrint_LinkClicked);
this.Controls.Add(printPage);
#endregion
}
示例2: set_TopDataColumn
private void set_TopDataColumn(Dictionary<string, ColumnSetting> dcs, DataTable dt)
{
TopflowLayoutPanel.SuspendLayout();
ColumnSetting cs = null;
foreach (DataColumn dc in dt.Columns)
{
if (dcs.ContainsKey(dc.ColumnName) && dcs[dc.ColumnName].Visiable)
{
cs = dcs[dc.ColumnName];
TableLayoutPanel tlp = new TableLayoutPanel();
tlp.RowCount = 1;
tlp.Parent = TopflowLayoutPanel;
tlp.Height = 32;
tlp.Show();
Label lleft = new Label();
lleft.Text = dcs[dc.ColumnName].HeadText;
lleft.Anchor = AnchorStyles.None;
lleft.AutoSize = true;
lleft.Show();
Control rtb = null;
if (cs.ReadOnly)
{
rtb = new Label() { BorderStyle= System.Windows.Forms.BorderStyle.FixedSingle };
}
else
{
rtb = new TextBox();
}
rtb.DataBindings.Add(new Binding("Text", topbs, dc.ColumnName, true));
rtb.Width = dcs[dc.ColumnName].Width;
rtb.Anchor = AnchorStyles.Left;
tlp.ColumnCount = 2;
rtb.Show();
tlp.Controls.AddRange(new Control[] { lleft, rtb });
tlp.SetColumn(lleft, 0);
tlp.SetColumn(rtb, 1);
//start list data link
if (cs.LinkData && !cs.ReadOnly) //列表数据类型
{
rtb.Tag = cs;
//这种委托不知道是否是共用,还是每个实例一个,待确定
MouseEventHandler rtb_right = delegate(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
//弹出窗体对话框,用于选择数据
SelectItemValue siv = SelectItemValue.Default;
TextBox rtb_tmp = (TextBox)sender;
ColumnSetting cs_rtb = (ColumnSetting)rtb_tmp.Tag;
siv.Text = string.Format("选择 {0} ...", cs_rtb.HeadText);
siv.SetColumnSetting(_dblClass, cs_rtb, ModelName, cs_rtb.HeadText);
if (siv.ShowDialog() == DialogResult.OK)
{
rtb_tmp.Text = siv.SelectValue;
}
}
};
rtb.MouseDoubleClick += rtb_right;
//tlp.ColumnCount = 3;
//ComboBox cb = new ComboBox();
//cb.Width = 20;
//cb.DropDownWidth = 200;
//cb.DropDownStyle = ComboBoxStyle.DropDownList;
//cb.TabIndex = 0;
//_dblClass.RefreshColumnSettingLinkData(ref _sqlcommand, dc.ColumnName); //更新数据
//cb.DataSource = cs.LinkDataTable;
//cb.DisplayMember = cs.LinkColumnName ;
////cb.DataBindings.Add("Text", cs.LinkDataTable, "Value");
//EventHandler _Commit = delegate(object sender, EventArgs e)
// {
// rtb.Text = cb.Text;
// };
//cb.SelectionChangeCommitted += _Commit;
//cb.Show();
//tlp.Controls.Add(cb);
//tlp.SetColumn(cb, 2);
}
//end list data link
tlp.AutoSize = true;
tlp.AutoSizeMode = AutoSizeMode.GrowAndShrink;
}
//有些列后添加的,但是需要显示,只是没有配置信息的情况
//此情况未处理
}
TopflowLayoutPanel.ResumeLayout();
}