using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace parentform
{
public partial class Form2 : Form
{
ToolStripLabel tsl;
public Form2()
{
InitializeComponent();
StatusStrip sb = new StatusStrip();
//事实上StatusStrip囊括了StatusBar,它的功能变得更强大。
tsl = new ToolStripLabel();
// tsl.Text = DateTime.Now.ToString ()
;//通过这种方式得到的只是静态的时间。
ToolStripItem[] tsi = new ToolStripItem[1];
tsi[0] = tsl;
sb.Items.AddRange(tsi);
this.Controls.Add(sb);
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("this is form2");
}
private void Form2_Load(object sender, EventArgs e)
{
//这里是设置label的宽度为screen的宽度,高度为30,左边距为0.上边距为0(距离自己的边距).
System .Drawing .Rectangle ss=System .Windows .Forms .Screen .GetWorkingArea (this);
label1.Width = ss.Width;
label1.Left = 0;
label1.Top = 0;
label1.Height = 30;
this.WindowState = FormWindowState.Maximized;//让该窗体最大化,注意,虽然最大化,但是还是作为子窗体。
}
private void statusStrip1_ItemClicked(object sender, ToolStripItemClickedEven
tArgs e)
{
}
private void
timer1_Tick(object sender, EventArgs e)
{
tsl.Text = DateTime.Now.ToString(); /
/能够动态的获得时间
}
}
}
注意:加上timer空间的时候,要设置
属性Enable=ture ,设置interval=1000.