Reputation: 2413
I need a UI control for a windows forms application. I don't know what the name of such UI is but I can describe what I want: I can to have a button on my form that when I hover the mouse over it, the CONTROL which I am looking for gets opened beside my form with animation and I want to add some buttons in that control. What is that control? Is there any such control in RAD Controls which I can use? I really appreciate your help.
Upvotes: 1
Views: 226
Reputation: 14102
What you need is another Form
with some customization (Perhaps removing the control box on top e.g. close, maximize and minimize). And you can open this form in your buttons MouseHover
event.
Something like:
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();
}
As for animation, you can search for animation for winformws on google.Or look here and there, something like : WinForms animation
Regarding your other question
If you want the new opened form to move with your move, then you need some changes. First you need to have the new form as a field in your code (then the button hover also should be changed):
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();
}
For keep both form moving together, you need to handle that in the Move
event of your main form, something like:
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);
}
}
Upvotes: 1