【问题标题】:C# smooth resize of the form (smooth resize efect)C# 表单的平滑调整大小(平滑调整大小效果)
【发布时间】:2019-04-09 22:13:03
【问题描述】:

首先,这里的初学者,如果我的问题有明显的答案,请提前道歉,但直到现在,我还没有弄明白。 所以,我正在尝试制作一个 Windows 窗体应用程序。在这个应用程序中,我有两种表单:登录表单和主窗口表单。为了让它看起来更“花哨”,成功登录后,主窗口窗体必须将其大小(与登录窗体大小相同)增加到更大。我设法创建了我需要的代码,但调整大小效果看起来“滞后”。有没有办法让这个窒息?还是有另一种方法可以使表单的大小调整更平滑? PS。我已将“FormBorderStyle”属性设置为“无” 贝娄,我的代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SlindingPanel
{


public partial class MainWindow : Form
{


    public MainWindow()
    {
        InitializeComponent();

        // Enables the timer
        timer1.Enabled = true;
    }



    private void timer1_Tick(object sender, EventArgs e)
    {
        if (this.Width >= 820 && this.Height >= 540) this.timer1.Enabled = false;

        else {
            // Resizes the form
            this.ClientSize = new System.Drawing.Size(Width + 20, Height + 20);
            //Centers the form on the screen
            this.CenterToScreen();

        }
    }


}

【问题讨论】:

  • 您一次调整 20 个像素的大小,您尝试过更短的间隔和更小的增量吗?
  • 看起来一样。只是表单的大小变慢了。
  • 您是否看到控件重绘缓慢?我想这种调整大小会在视觉上很混乱,尤其是在 Windows 窗体应用程序中,你能不使用其他技术,如 wpf 吗?
  • 我不知道 wpf。我是 C# 新手。但是,谢谢你的想法。我会做一些研究,看看如何更改我的应用程序。

标签: c# forms


【解决方案1】:

这可能会晚,但我建议使用 UI 控件的“锚”属性。

【讨论】:

    猜你喜欢
    • 2019-04-30
    • 1970-01-01
    • 1970-01-01
    • 2013-08-17
    • 1970-01-01
    • 2016-10-21
    • 1970-01-01
    • 1970-01-01
    • 2010-10-18
    相关资源
    最近更新 更多