C#加载和隐藏页面

huangapple go评论68阅读模式
英文:

C# Loading and hiding page

问题

我有一个C#项目,包含两个窗体:一个加载窗体和一个登录窗体。加载窗体有一个圆形进度条和一个定时器,定时器更新进度条直到加载完成。当加载窗体加载完成后,它应该隐藏,然后显示登录窗体。然而,我遇到一个问题,加载窗体在隐藏之前会稍微改变位置,我不确定为什么会发生这种情况。

我已经尝试了一些基本的故障排除步骤,比如检查窗体的Anchor和Dock属性,但问题仍然存在。有其他人在使用定时器和圆形进度条时遇到类似问题的吗?有没有关于如何解决的建议?

英文:

I have a C# project with two forms: a loading form and a login form. The loading form has a circular progress bar and a timer that updates the progress bar until it's finished loading. When the loading form finishes loading, it's supposed to hide and the login form appears. However, I'm experiencing an issue where the loading form changes position slightly before hiding, and I'm not sure why this is happening.

I've tried some basic troubleshooting steps, such as checking the form's Anchor and Dock properties, but the issue still persists. Has anyone else experienced a similar issue when using a timer and circular progress bar and have any suggestions on how to fix it?

答案1

得分: 0

我建议的一件事,对于任何项目通常不要打开/关闭太多窗体,而是在一个主窗体上加载新的窗体。

这可能会有助于减少您所经历的抖动/闪烁,并总体上提高应用程序的外观。

要将窗体添加到面板:

Form someForm = new Form();
someForm.TopLevel = false;
myPanel.Add(someForm);
someForm.Show();

请注意,您必须将子窗体的顶级属性设置为false。这种处理窗体的方法将减少项目中打开/关闭的动画和任何图形故障。

英文:

One thing I would recommend, for any project in general is not opening/closing so many forms but rather loading new forms inside a panel that is on one main form.

This would maybe help with the jittering/glitching that you are experiencing and in general will improve the overall appearance of your application.

To add a form to a panel:

Form someForm = new Form();
someForm.TopLevel = false;
myPanel.Add(someForm);
someForm.Show();

Note that you must set the child form's top level property to false. This method of handling forms overall will reduce the opening/closing animations of your project and any graphics glitching.

huangapple
  • 本文由 发表于 2023年2月17日 23:52:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/75486501.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定