码迷,mamicode.com
首页 > 其他好文 > 详细

车辆售票坐位图

时间:2016-01-24 19:32:17      阅读:112      评论:0      收藏:0      [点我收藏+]

标签:


private void button1_Click(object sender, EventArgs e)
{

int num=0;

string strchar;
string str = "";
num = textBox1.Text.Length;

str = textBox1.Text;

textBox2.Text = Convert.ToString(num);


tableLayoutPanel1.GetType().GetProperty("DoubleBuffered", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).SetValue(tableLayoutPanel1, true, null);

// tableLayoutPanel1.AutoScroll = true;
// tableLayoutPanel1.BackColor = Color.White;
// tableLayoutPanel1.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single;
// tableLayoutPanel1.ColumnCount = 6;


tableLayoutPanel1.Controls.Clear();

for (int i = 0; i < num ; i++)
{
// ——行和列的 样式 默认为auto
//tableLayoutPanel4.ColumnStyles.Add(new ColumnStyle());
//tableLayoutPanel4.RowStyles.Add(new RowStyle());



strchar = str.Substring(i, 1);

 

 

 

Label lab = new Label();
// lab.Name = "Label_" + i;
// lab.Text = "Label_" + i;

lab.Text = Convert.ToString( i+1);

lab.Font = new Font(label1.Font.FontFamily, 15,label1.Font.Style);

switch (strchar)
{
case "0":
//Console.WriteLine("很棒!");

lab.BackColor = Color.White;
break;

case "1":
lab.BackColor = Color.Red;
break;
case "2":
lab.BackColor = Color.Yellow;
break;
default:
lab.BackColor = Color.White;
break;
}

// lab.Text = strchar;

lab.AutoSize = true;
//通过Anchor 设置Label 列中居中
lab.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));


tableLayoutPanel1.Controls.Add(lab);

 

 


// TextBox txtObj = new TextBox();
// txtObj.Text = "TextBox_" + i;
// txtObj.Width = 70;
// tableLayoutPanel1.Controls.Add(txtObj);
}
}

车辆售票坐位图

标签:

原文地址:http://www.cnblogs.com/jiangyuxuan/p/5155632.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!