I can't seem to figure out what I'm doing wrong. I want the panel to be hidden when program launch, but when user move the mouse over the panel area, then panel becomes visible. I try different ways but i must be missing something. Here is current code. Also the visible property is set to false.
private void plMain_MouseEnter(object sender, EventArgs e)
{
if (plMain.Visible == false)
plMain.Visible = true;
}
private void plMain_MouseLeave(object sender, EventArgs e)
{
if (plMain.Visible == true)
plMain.Visible = false;
}
11 replies to this topic
#1
Posted 26 January 2011 - 03:04 AM
|
|
|
#2
Posted 26 January 2011 - 12:48 PM
You can use a mouse enter on a invisible object. One solution is to just change the background color of the panel:
EDIT: Thid works better:
~ Committed.
EDIT: Thid works better:
private void panel1_MouseLeave(object sender, EventArgs e)
{
panel1.BackColor = Color.Transparent;
}
private void panel1_MouseEnter(object sender, EventArgs e)
{
panel1.BackColor = Color.WhiteSmoke;
}
~ Committed.
A man can be defined by what he does when no one is looking.
Science is only an educated theory, which we cannot disprove.
Science is only an educated theory, which we cannot disprove.
#3
Posted 26 January 2011 - 12:56 PM
The panel will display settings and options. So I need it to be invisible and visible at times. Will also try other options, either mouseMove, or mouseHover, or anything else I can do to get this to work.
#4
Posted 26 January 2011 - 01:04 PM
OK, now i have some better working code.
Hope this works ~ Committed. :)
public Form1()
{
InitializeComponent();
panelColor = panel1.BackColor;
}
Color panelColor = new Color();
private void panel1_MouseLeave(object sender, EventArgs e)
{
panel1.BackColor = Color.Transparent;
}
private void panel1_MouseEnter(object sender, EventArgs e)
{
panel1.BackColor = panelColor;
}
You will still have to turn the labels and buttons on the panel invisible, and visible on the mouseEnter, and mouseLeave events.Hope this works ~ Committed. :)
A man can be defined by what he does when no one is looking.
Science is only an educated theory, which we cannot disprove.
Science is only an educated theory, which we cannot disprove.
#5
Posted 26 January 2011 - 01:31 PM
Ok, from your ideal I came up with this, because I couldn't get rid of the border and text in buttons with your code.
Problem is; works great with the panel, but when I go over the buttons they keep flicking.
private void plMain_MouseLeave(object sender, EventArgs e)
{
plMain.BackColor = Color.Transparent;
btnExit.Visible = false;
btnHome.Visible = false;
btnSettings.Visible = false;
}
private void plMain_MouseEnter(object sender, EventArgs e)
{
plMain.BackColor = Color.Turquoise;
btnExit.Visible = true;
btnHome.Visible = true;
btnSettings.Visible = true;
}
private void btnExit_MouseEnter(object sender, EventArgs e)
{
plMain.BackColor = Color.Turquoise;
btnExit.Visible = true;
btnHome.Visible = true;
btnSettings.Visible = true;
}
private void btnExit_MouseLeave(object sender, EventArgs e)
{
plMain.BackColor = Color.Transparent;
btnExit.Visible = false;
btnHome.Visible = false;
btnSettings.Visible = false;
}
private void btnHome_MouseEnter(object sender, EventArgs e)
{
plMain.BackColor = Color.Turquoise;
btnExit.Visible = true;
btnHome.Visible = true;
btnSettings.Visible = true;
}
private void btnHome_MouseLeave(object sender, EventArgs e)
{
plMain.BackColor = Color.Transparent;
btnExit.Visible = false;
btnHome.Visible = false;
btnSettings.Visible = false;
}
private void btnSettings_MouseEnter(object sender, EventArgs e)
{
plMain.BackColor = Color.Turquoise;
btnExit.Visible = true;
btnHome.Visible = true;
btnSettings.Visible = true;
}
private void btnSettings_MouseLeave(object sender, EventArgs e)
{
plMain.BackColor = Color.Transparent;
btnExit.Visible = false;
btnHome.Visible = false;
btnSettings.Visible = false;
}
Problem is; works great with the panel, but when I go over the buttons they keep flicking.
#6
Posted 26 January 2011 - 01:47 PM
Hmm, cant you just use this code?
~ Committed.
private void plMain_MouseLeave(object sender, EventArgs e)
{
plMain.BackColor = Color.Transparent;
btnExit.Visible = false;
btnHome.Visible = false;
btnSettings.Visible = false;
}
private void plMain_MouseEnter(object sender, EventArgs e)
{
plMain.BackColor = Color.Turquoise;
btnExit.Visible = true;
btnHome.Visible = true;
btnSettings.Visible = true;
}
It doenst flash, or do you really need to have the buttons appear when you hover?~ Committed.
A man can be defined by what he does when no one is looking.
Science is only an educated theory, which we cannot disprove.
Science is only an educated theory, which we cannot disprove.
#7
Posted 26 January 2011 - 02:05 PM
It still flickers for me. So I tried it on another form, with same setup, and the same thing, but also realized that when i use transparent, it cover up things under it, (ie.. my browser and listbox).
Question, how do you make a item that is invisible,visible. I got the mouse leave event to work with visible = false, just can't get it to work the other way.
Question, how do you make a item that is invisible,visible. I got the mouse leave event to work with visible = false, just can't get it to work the other way.
#8
Posted 27 January 2011 - 08:40 AM
IM not sure you cna do that.
THis code may work:
THis code may work:
private void plMain_MouseLeave(object sender, EventArgs e)
{
panel1.SendToBack();
}
private void plMain_MouseEnter(object sender, EventArgs e)
{
panel1.BringToFront();
}
A man can be defined by what he does when no one is looking.
Science is only an educated theory, which we cannot disprove.
Science is only an educated theory, which we cannot disprove.
#9
Posted 27 January 2011 - 09:36 AM
Going to try something in a little bit, will post soon if it works.
#10
Posted 27 January 2011 - 01:08 PM
Ok, I finally got it to work, here is the working code.
private void plOsMain_MouseEnter(object sender, EventArgs e) //****Outside Panel to trigger the event.
{
plMain.Visible = true;
btnExit.Visible = true;
btnHome.Visible = true;
BtnSettings.Visible = true;
timeMP.Enabled = true;
timeMP.Interval = 1500;
timeMP.Tick += new System.EventHandler(timeMP_Tick);
}
private void timeMP_Tick(object sender, EventArgs e)
{
plMain.Visible = false;
btnExit.Visible = false;
btnHome.Visible = false;
BtnSettings.Visible = false;
}
#11
Posted 27 January 2011 - 02:04 PM
Good for you! Sorry I wasnt able to fix your problem.
~ Committed.
~ Committed.
A man can be defined by what he does when no one is looking.
Science is only an educated theory, which we cannot disprove.
Science is only an educated theory, which we cannot disprove.
#12
Posted 27 January 2011 - 02:09 PM
Thanks your your help, for everything.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account


Back to top









