1

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

4

1 回答 1

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 动画

关于你的另一个问题

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

    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);

         }
}
于 2012-09-04T06:14:12.383 回答