Click here to Skip to main content
15,886,822 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I drawn a path(using coordinates of selecting area) in the panel.In this I want to display the values while hovering on the panel path.How will I do this? Please Help Me !

What I have tried:

C#
points1.Add(new Point(Convert.ToInt16(x), Convert.ToInt16(y)));
Pen p = new Pen(Color.Blue, 2);
Graphics gr = Graphics.FromImage(panelname.BackgroundImage);
gr.SmoothingMode = SmoothingMode.AntiAlias;                  
AdjustableArrowCap bigArrow = new AdjustableArrowCap(5, 5);                  
p.CustomEndCap = bigArrow;                           
g.DrawLine(p, points1[i1], points1[i1 + 1]);


This is only for path display in panel.I don't know how to display value over the path while mouse hover the path.Guide me !!
Posted
Updated 18-Jul-17 3:20am
v4
Comments
Ralf Meier 18-Jul-17 6:19am    
I'm not quite sure what you try to achieve ...

Generally you should create your own customized Control (perhaps it derives from Panel but it could also derive from Control) and override the OnPaint-Method in it.
So all action only happens inside the control.
Santhosh1217 18-Jul-17 6:46am    
Thank you very much for your Reply Sir !!
I don't know how to explain it properly but i will try...

The panel contains image.I click the panel periodically and also I note the Coordinates.Later I used this coordinates to draw a path.The Path will join from one click to another click.I want to Show the message(Coordinates and some others data)using tool tip while mouse is move on that path.
Ralf Meier 18-Jul-17 8:10am    
OK ... then create a customized Panel which detects each Mouse-Click (by overriding the OnMouseClick-Method) and store it's coordinates in a List <point>. To get this List outside the Panel you could (for example) use a Property with the same type ...
Santhosh1217 18-Jul-17 8:20am    
Sorry to disturbing you !! Can you please explain with the example ?
Ralf Meier 18-Jul-17 9:21am    
take a look at my Solution ...

1 solution

An example for this could be :
C#
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
public class myPanel : Panel
{

	public List<Point> ClickPoints {
		get { return myClickPoints; }
		set { myClickPoints = value; }
	}

	private List<Point> myClickPoints = new List<Point>();
	public void ClearList()
	{
		myClickPoints.Clear();
	}

	protected override void OnMouseClick(MouseEventArgs e)
	{
		myClickPoints.Add(new Point(e.Location.X, e.Location.Y));
		base.OnMouseClick(e);
		this.Invalidate();
	}

	protected override void OnPaint(PaintEventArgs e)
	{
		e.Graphics.DrawString(myClickPoints.Count.ToString, Font, Brushes.Black, new Point(0, 10));

		base.OnPaint(e);
	}

}
 
Share this answer
 

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