• 车辆售票坐位图



    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);
    }
    }

  • 相关阅读:
    微信开放平台(公众号第三方平台) -- 全网发布
    SQL 邮件配置篇
    让BI告诉你:圣诞老人去哪了?
    锁定和行版本控制
    数据库质疑修复总结(转)
    抢救损坏数据库中的数据
    将 PAGE_VERIFY 数据库选项设置为 CHECKSUM
    replicate复制函数
    @@IDENTITY与SCOPE_IDENTITY()
    RESTORE DATABASE的standby选项
  • 原文地址:https://www.cnblogs.com/jiangyuxuan/p/5155632.html
Copyright © 2020-2023  润新知