c#中使用状态栏

c#中使用状态栏

  (2009-05-07 09:29:37)
标签: 

it

分类: c#,ASP
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.

1

0

阅读 (1162)   评论  (0) 收藏 (0)  转载 (0)   喜欢   打印 举报
已投稿到:
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值