鼠标悬停在面板上时显示值。 [英] Display values while mouse hover on panel.

查看:102
本文介绍了鼠标悬停在面板上时显示值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在面板中绘制了一条路径(使用选择区域的坐标)。在此我想在面板路径上悬停时显示值。我该怎么做?请帮帮我!



我的尝试:



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:

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 !!

推荐答案

这方面的一个例子可能是:
An example for this could be :
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);
	}

}


这篇关于鼠标悬停在面板上时显示值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆