表格之间的过渡 [英] Transition between Forms

查看:108
本文介绍了表格之间的过渡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
请我如何从一种形式转移到另一种形式?例如,我单击按钮,然后立即显示另一个表格.
我知道唯一的方法就是隐藏一个并显示另一个,但是它看起来很糟糕,因为它会闪烁(很短的时间,但是仍然).有没有隐藏的方法吗?
编写我现在使用的代码:

Hello,
Please how do I move from one form to another? For example I click on the button and another form immediately show.
I know the only way and thats hiding one and showing another but it looks bad because it flickers (for very short time but still). Is there some way to do it without hiding?
Code what I use now to to that:

this.Hide();
Form2 secondtform = new Form2();
secondform.Show();



但这会导致显示其他图标的图标消失.因此,我希望可以采用某种方法使它看起来像您在正常的Windows程序中移动一样.

刚刚尝试过此代码以摆脱闪烁



but this cause disappearing icon showing another etc.. So I hoped there is some way to make this look like you are moving across normal windows program.

Just tried this code to get rid of flickering

public void EnableDoubleBuffering()
{
   this.SetStyle(ControlStyles.DoubleBuffer |
      ControlStyles.UserPaint |
      ControlStyles.AllPaintingInWmPaint,
      true);
   this.UpdateStyles();
}


不幸的是,它并没有解决它..


Unfortenately it doesn''t solved it..

推荐答案

你好,

试试这个:

Hello,

Try this:

private Form2 form2;
public Form1()
{
    InitializeComponent();

    this.form2 = new Form2();
    //form2.Show();
    HideForm(form2);
}

private void ShowButton_Click(object sender, EventArgs e)
{
    ShowForm(form2);
    HideForm(this);
}

private int height;
private int width;
private System.Windows.Forms.FormBorderStyle borderStyle;

private void ShowForm(Form form)
{
    form.Visible = true;
    form.FormBorderStyle = borderStyle;
    form.Height = height;
    form.Width = width;
}

private void HideForm(Form form)
{
    height = form.Height;
    width = form.Width;
    borderStyle = form.FormBorderStyle;

    form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
    form.Height = 0;
    form.Width = 0;
    form.Visible = false;
}


通常,除了Form.ShowForm.ActivateForm.BringToFront之外,您不需要其他任何东西,请参见:
http://msdn.microsoft.com/en-us/library/system. windows.forms.form.aspx [ ^ ].

如果此指示灯闪烁,则很可能是您做错了什么.如果没有一些代码示例来说明问题,那么很难说出什么.以防万一:查看我最近的反点击器建议:
Normally, you don''t need anything else but Form.Show, Form.Activate or Form.BringToFront please see:
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.aspx[^].

If this flickers, most likely you did something wrong. It''s hard to say what, without having some code sample to manifest the problem. Just in case: look at my recent anti-clicker advice: Question about change form to full screen mode but my form flashing[^].

—SA


这篇关于表格之间的过渡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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