【问题标题】:I need a UI Control for .net windows forms application我需要一个用于 .net windows 窗体应用程序的 UI 控件
【发布时间】:2012-09-04 04:38:54
【问题描述】:

我需要一个用于 Windows 窗体应用程序的 UI 控件。我不知道这种 UI 的名称是什么,但我可以描述我想要的:我可以在我的表单上有一个按钮,当我将鼠标悬停在它上面时,我正在寻找的 CONTROL 在我的表单旁边打开带有动画,我想在该控件中添加一些按钮。那是什么控制?我可以使用 RAD Controls 中的任何此类控件吗?非常感谢您的帮助。

【问题讨论】:

    标签: .net winforms user-interface


    【解决方案1】:

    您需要另一个 Form 进行一些自定义(可能移除顶部的控制框,例如关闭、最大化和最小化)。您可以在按钮MouseHover 事件中打开此表单。 比如:

    private void MyButton_MouseHover(object sender, EventArgs e)
    {
    //Assume that you made this form in designer
    var cutomForm = new CustomForm(); 
    //Set the opening location somewhere on the right side of main form, you can change it ofc
    cutomForm.Location = new Point(this.Location.X + this.Width, this.Height / 2);
    //Probably topmost is needed
    cutromForm.TopMust = true;
    customForm.Show();
    }
    

    关于动画,你可以在google上搜索winformws的动画。或者到处看看,比如:WinForms animation

    关于您的其他问题

    如果您希望新打开的表单随着您的移动而移动,那么您需要进行一些更改。首先,您需要将新表单作为代码中的一个字段(然后按钮悬停也应该更改):

        private CustomForm _customForm;
    
         private void MyButton_MouseHover(object sender, EventArgs e)
        {
          //Check if customForm was perviously opened or not
          if(_customForm != null)
              return;
    
          //Assume that you made this form in designer
          _customForm= new CustomForm(); 
          //Set the opening location somewhere on the right side of main form, you can change it ofc
          _customForm.Location = new Point(this.Location.X + this.Width, this.Height / 2);
          //Probably topmost is needed
          _customForm.TopMust = true; 
    
          //Delegate to make form null on close
          _customForm.FormClosed += delegate { _customForm = null;};   
          _customForm.Show();
        }
    

    为了让两个表单一起移动,您需要在主表单的 Move 事件中处理它,例如:

    private void Form1_Move(object sender, EventArgs e)
    {
             if(_customForm != null)
             {
              //Not sure if this gonna work as you want but you got the idea I guess
              _customForm.Location = new Point(this.Location.X + this.Width, this.Height / 2);
    
             }
    }
    

    【讨论】:

    • 非常感谢您的好回答,我希望打开表格贴在其父级的右上角,我该怎么做才能做到这一点?我的意思是,即使父母正在移动,我也希望打开的表单能粘在父母身上
    • @Karamafrooz mokhlesim.
    猜你喜欢
    • 2019-11-20
    • 1970-01-01
    • 1970-01-01
    • 2023-04-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-21
    相关资源
    最近更新 更多