自动查看c#中的表单窗口? [英] auto view Form window in c# ?

查看:69
本文介绍了自动查看c#中的表单窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我有三种形式(Form1,Form2,Form3)

i尝试查看Form1然后1分钟后出现Form2然后1分钟后出现form3然后重复这个

自动

可以帮助我:)

解决方案

查看Form1页面的代码

 public partial class Form1:Form 
{
public Form1()
{
InitializeComponent();
}
定时器t =新的定时器();
private void Form1_Load(object sender,EventArgs e)
{
t.Interval = 1000 * 60; // 1sec * 60 = 1 min;
t.Enabled = true;
t.Tick + = t_Tick;
}
static int counter = 1;
void t_Tick(object sender,EventArgs e)
{
if(counter == 1)
{
Form2 frm = new Form2();
frm.Show();
}
else if(counter == 2)
{
Form3 frm = new Form3();
frm.Show();
}
counter + = 1;
}
}


从UI的角度来看,这可能是一个坏主意 - 但这是可能的。

我这样做的方法是创建一个主表单,该表单不可见,但包含三个表单实例 - 每个表单实例一个。

添加一个每个表单的处理程序,处理FormClosed事件 - 并关闭其中的主窗体。

将一个计时器添加到主窗体,并将其设置为一分钟间隔。

在Tick事件中,检查您正在显示的表格,然后在实例上调用Hide,在下一个表单上显示。



但是来自用户POV,它会非常难看。



我模仿的方式是将我的三个表单中的每一个放入UserControl中,然后更改哪个其中一个显示我的主要和唯一的形式。这样,主表单的框架和大小/位置得以保持,用户不必担心或被打扰。


Hi
只需每个页面的用户计时器并设置1分钟,在第一个形式的计时器遇到1分钟然后打电话给表格2和关闭表格1,然后表格2会议1分钟然后打电话给表格3并关闭第二表格并形成3个电话第一表格并关闭第三表格......就像那样你好。



在计时器打勾事件中你打电话给下一个,每个页面的下一个表单计时器打勾事件,设置计时器的间隔。



显示表格并关闭



 Form2.show() ShowDialog()
Form1.close()





注:

打开下一个表格然后只关闭当前表格,否则不工作





问候

阿拉汶


hello
I have three forms ( Form1 , Form2 , Form3 )
i try to view Form1 then after 1 min appear Form2 then after 1 min appear form3 then repeat this
automatically
can help me :)

解决方案

See the code of Form1 page

public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        Timer t = new Timer();
        private void Form1_Load(object sender, EventArgs e)
        {
            t.Interval = 1000 * 60;//1sec*60=1 min;
            t.Enabled = true;
            t.Tick += t_Tick;
        }
        static int counter = 1;
        void t_Tick(object sender, EventArgs e)
        {
            if (counter == 1)
            {
                Form2 frm = new Form2();
                frm.Show();
            }
            else if (counter == 2)
            {
                Form3 frm = new Form3();
                frm.Show();
            }
            counter += 1;
        }
    }


This is probably a bad idea, from a UI point of view - but it is possible.
The way I'd do it is to create a "Main" form which is not visible, but which contains three form instances - one for each of your other forms.
Add a handler to each of these forms, to handle the FormClosed event - and Close the Main form in it.
Add a Timer to the Main form, and set it to a one minute interval.
In the Tick event, check which form you are displaying, then call Hide on the instance, and Show on the next one.

But from a user POV, it's going to be pretty ugly.

The way I'd emulate that would be to put each of my three forms into a UserControl instead, and then change which one of these my main-and-only form displayed. That way the frame and size / position of the main form is maintained without the user having to faff about or be disturbed.


Hi Just user timer for each page and set 1 mins,in first form timer meets 1 mins then call form 2 and close form 1,then form 2 meets 1 mins then call form 3 and close second form and form 3 call first form and close 3rd form ......like that u do.

in timer tick event u call next,next form in each page timer tick event,set interval for timer.

For show form and close

Form2.show() or ShowDialog()
Form1.close()



Note:
After u open a next form then only u close current form ,otherwise not work


Regards
Aravind


这篇关于自动查看c#中的表单窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆