酒店管理系统房态图的效果制作

没什么技术含量就是给自己一个记忆的空间。
   1:          private void bnt_在住房_Click(object sender, EventArgs e)
   2:          {
   3:              for (int i = 0; i < Convert.ToInt32(textBox1.Text); i++)
   4:              {
   5:                  // Label lb = new Label();//本来是用标签的,后来发现用按钮更好。
   6:                  Button lb = new Button(); //声明一个按钮型的变量,并实例化;
   7:                  lb.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);//设置控件之间的距离;
   8:                  lb.Width = 80;                  //设置宽度为80;
   9:                  lb.Height = 80;                 //设置高度为80;
  10:                  lb.Text = i.ToString("000")+"\n\t标准单人间";    //把循环变量I转换成字符串类型;
  11:                  lb.BackColor = Color.PowderBlue;//设置控件的背景色;
  12:                  lb.ForeColor = Color.Red;       //设置控件的前景色为红色,也就是文字的颜色;
  13:                  lb.TextAlign = ContentAlignment.TopCenter;
  14:                  //lb.MouseMove += new MouseEventHandler(button_MouseMove);                
  15:                  lb.Click += new System.EventHandler(this.clearButton_Click);//用委托实现让控件响应单击事件;              
  16:                  //lb.MouseLeave += new EventHandler(button_MouseLeave);
  17:                  //lb.Image = Image.FromFile(@"F:/VS2008ImageLibrary/Actions/AddTableHH.bmp");//设置控件的图片;
  18:                  lb.ImageAlign = ContentAlignment.MiddleCenter;//设置控件上的图片对齐方式;
  19:                  for (int n = 0; n < 3; n++)
  20:                  {
  21:                      Label lb1 = new Label();
  22:                      lb1.BackColor = Color.SlateGray;
  23:                      lb1.Location = new Point(n * 20 + 7, 60);
  24:                      lb1.Width = 10;
  25:                      lb1.Height = 11;
  26:                      lb.Controls.Add(lb1);
  27:                  }
  28:                  this.flowLayoutPanel1.Controls.Add(lb);
  29:              }
  30:          }

下面是效果图。

image

posted @ 2012-11-17 01:15  前方辉煌  阅读(7680)  评论(2编辑  收藏  举报