zoukankan      html  css  js  c++  java
  • 车辆售票坐位图


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

  • 相关阅读:
    浮起来的验证消息
    关于jQuery UI 使用心得及技巧
    如何制作好一个提交按扭我是个爱折腾的人
    ABAP自测试题一 沧海
    商务出现问题 沧海
    [转帖]Report painter 沧海
    准备ABAP认证 沧海
    Characteristics and Key figures In Report Painter 沧海
    有朋自远方来 沧海
    What are the layers of data description in R/3? 沧海
  • 原文地址:https://www.cnblogs.com/jiangyuxuan/p/5155632.html
Copyright © 2011-2022 走看看