标签:
一、MDI窗体
1 private void 添加窗体ToolStripMenuItem_Click(object sender, EventArgs e) 2 { 3 Form2 frm1 = new Form2(); 4 frm1.MdiParent = this; 5 frm1.Show(); 6 Form3 frm2 = new Form3(); 7 frm2.MdiParent = this; 8 frm2.Show(); 9 } 10 private void 横向排列ToolStripMenuItem_Click(object sender, EventArgs e) 11 { 12 LayoutMdi(MdiLayout.TileHorizontal); 13 } 14 private void 纵向排列ToolStripMenuItem_Click(object sender, EventArgs e) 15 { 16 LayoutMdi(MdiLayout.TileVertical); 17 }
二、字符串的截取
1 //截取字符串:Text.Substring(1),截取第一个字符后面的所有 2 // Text.Substring(1,2),截取第一个字符后面的的两个字符 3 private void timer1_Tick(object sender, EventArgs e) 4 { 5 l1.Text = l2.Text = l1.Text.Substring(1) + l2.Text.Substring(0, 1); 6 l4.Text = l3.Text = l3.Text.Substring(2) + l3.Text.Substring(1, 2); 7 }
三、播放音乐
1 using System.Media; //导入 2 SoundPlayer muise = new SoundPlayer(); 3 muise.SoundLocation = @"..\..\1.wav"; //路径 4 muise.Play();
四、获取时间
1 private void timer2_Tick(object sender, EventArgs e) 2 { 3 label5.Text = DateTime.Now.ToString();//显示为:2016-04-16 11:59:36 4 int h = DateTime.Now.Hour; //小时 5 int m = DateTime.Now.Minute;//分钟 6 int s = DateTime.Now.Second;//秒 7 }
五、坐标
1 //this.ClientSize.Height 主窗体高度 2 //btnDui.ClientSize.Height 按钮控件高度 3 // x,y即可改变控件位置 4 //this.btnDui.Location = new System.Drawing.Point(x, y); 5 public int x = 180; //x轴坐标 6 public int y = 30; //y轴坐标 7 private void btnS_Click(object sender, EventArgs e) 8 { 9 if (this.ClientSize.Height - y - btnDui.ClientSize.Height <= 0) 10 { 11 MessageBox.Show("移到底了!"); 12 return; 13 } 14 else 15 { 16 y += 10; 17 this.btnDui.Location = new System.Drawing.Point(x, y); 18 } 19 }
//另外补充
this.btnDui.BackColor = System.Drawing.Color.Green;//改变按钮的背景色
int h=this.btnDui.Size.Height; //获取按钮高度
string a=Convert.ToString( h );
MessageBox.Show(a);
标签:
原文地址:http://www.cnblogs.com/gx-143/p/5398115.html