Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hey guys,

if you reccognized im new here and i would appriciate that you tell me if im doing something wrong here!
Thank you =)

So i will come to my problem, imagine a window with pictureboxes and amount of click events etc.

Now i have inserted a panel with the height of the window, and the width of 20px.
I want that this panel, gets an event onclick, hover, mouseleave, drag. And it should always be in the front, so that the pictureboxes are invisible, just the panel would be visible.

- if i hover that panel it should pop a little bit out, like 20px.

- if i click that panel it should get the size of the programming window.

- mouseleave, the panel should return like it was, but thats not the problem.

- and just for fun, afterwards, i would like to create a drag event, if i drag a little picturebox in the panel like 200px to the left side, the panel should cover the whole window, like the click event.


So i hope i have given you the right informations for what i want, if not please tell me!

Thank you

Greets niko
Posted
Comments
OriginalGriff 9-Oct-12 3:56am    
And what have you tried?
niko_tells 9-Oct-12 4:16am    
following i have tried: private void Panel_Extras_MouseHover(object sender, EventArgs e)
{
Panel_Extras.Height = 750;
Panel_Extras.Width = 40;
Panel_Extras.Location = new Point(1410,0);

}

but thats bad in my mind, cause the window could change his width, this i ment by: new Point and the value 1410. I would ruther prefere to tell them, get window width, and pop +2% out.

MouseHover[^], MouseClick[^] and MouseLeave[^] are all events of the System.Windows.Forms.Panel[^] class. You can subscribe a method to each of them and in those methods, set the panel's Location[^] and Size[^] properties as you wish.
 
Share this answer
 
Comments
niko_tells 9-Oct-12 4:17am    
if i accept your solution the thread goes solved or you just get points for good awnsers?
lukeer 9-Oct-12 4:32am    
I'll get points _and_ the thread will be marked as solved.
niko_tells 9-Oct-12 4:35am    
but that aint solved ^^, for the future what should i do if im in that case again? give you 5 stars or mark as solved, even if my thread isnt solved?
lukeer 9-Oct-12 4:42am    
I'm happy with 5 stars if the answer is good. Accept the solution if it answers your question completely. Or you can accept several solutions that answer your question when combined.
"following i have tried:
C#
private void Panel_Extras_MouseHover(object sender, EventArgs e)
		{
			Panel_Extras.Height = 750;
			Panel_Extras.Width = 40;
			Panel_Extras.Location = new Point(1410,0);
			
		}


but thats bad in my mind, cause the window could change his width, this i ment by: new Point and the value 1410. I would ruther prefere to tell them, get window width, and pop +2% out."

Indeed it is: try
C#
Panel_Extras.Height = Height;
Panel_Extras.Width = 40;
PanelExtras.Location = new Point((int) ((float) Width * 1.02), 0);
Width and Height will pick up the Form width and height (or whatever the current class is based on)
 
Share this answer
 
Comments
niko_tells 9-Oct-12 4:32am    
Thank you for your very good awnser!
Ok i understand width and height now, but 1.02, 1 stays for increasing, 0 would be for decreasing? .02 is ment by 2%. I wanted to change the value, but it doesnt really change anything, how can i know wich class is based on that?

ps.: if i accept your awnser this thread is solved? if yes, i cant to it, cause there are awnseres open.
lukeer 9-Oct-12 4:38am    
"Width * 1.02" is the same as "102% of Width". Or "Two percent more than Width".
niko_tells 9-Oct-12 4:52am    
ah i could have the reason why it doesnt increases the width, the panel is on the right border of the window and should increse the size/position to left. So i tried instead of 1.02 -> 0.98. But that doesnt change, its the same funktion like 1.02. I have also tried 10.00, to discover if this is a child of another element and not of form. And 10.00 also didnt change nothing, its like 1.02. Now getting depressed ^^
OriginalGriff 9-Oct-12 5:02am    
It is possible that 1.02 is not changing anything because the numbers involved are too small and the point is an integer value: adding 2% to a small number may not generate a different integer!

Bear in mind that Width is the container control width - so you don't really want to use that in order to "pop" it out a little - you want to move it a small amount relative to it's original position.

So try storing it's location (outside the MoveHover event handler) and set it to that plus (say) 5 pixels in both X and Y. That should produce a better "Pop" effect. (Don't forget that MouseHover can occur more than once, so you probably don't want to add an amount each time - hence storing the original location outside the event handler)
niko_tells 9-Oct-12 5:27am    
For some reasons its hard to understand you, my english isnt the best -.-

I think you will advice me that i create a variable out of the hover. ex.: int PopX =5

And than entering this variable like that into hover: PanelExtras.Location = new Point((int) (PopX, 0);

I know that this is not possible.

To the comment with width, thank you for that, so i conclused that i need another referenze for width, i tried to get the form1 width but that command is also not possible.
If you have a panel then it will use like it . . .

C#
pnlPopUp.Visible = true;
pnlPopUp.Height = 1100;
pnlOffer.Style.Add("top", "180px");
pnlOffer.Visible = true;
 
Share this answer
 
v2
Comments
niko_tells 9-Oct-12 4:41am    
im not sure if this is "dynamic" cause if i change the window width your code would look crappy

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900