代码改变世界

winform技巧一,errorprovider,任务栏可见,总在最前

2008-05-25 13:48  Virus-BeautyCode  阅读(1355)  评论(0编辑  收藏  举报
 private void Form6_Load(object sender, EventArgs e)
        
{
            
this.ShowInTaskbar = false;//确定窗体是否在任务栏可见
            this.TopMost = true;//确定窗体总在最前显示,尽管没有获得焦点
        }

private void textBox1_Validating(object sender, CancelEventArgs e)
        {
            if (textBox1.TextLength < 5)
            {
                errorProvider1.SetError((Control)sender, "input must more than 5.");
                textBox1.SelectAll();
                e.Cancel = true;
            }
            else
            {
                errorProvider1.SetError((Control)sender, "");
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            for (int i = 1; i < 1000; i++)
            {
                this.progressBar1.Value++;
               
                this.label1.Refresh();this.label1.Text = Convert.ToString(progressBar1.Value);
            }
        }