如何画出两条垂直的线,跟随着鼠标的移动而移动。 如何画出两条垂直的线,跟随着鼠标的移动而移动。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace WindowsApplication1{ public partial class Form1 : Form { Point OldPoint; Pen OldPen, NewPen; public Form1() { InitializeComponent(); OldPoint = new Point(0, 0); OldPen = new Pen(this.BackColor); NewPen = new Pen(this.ForeColor); } private void Form1_MouseMove(object sender, MouseEventArgs e) { Graphics My = this.CreateGraphics(); //旧横线 My.DrawLine(OldPen, OldPoint.X, 0, OldPoint.X, this.Size.Width); //旧竖线 My.DrawLine(OldPen, 0, OldPoint.Y, this.Size.Width, OldPoint.Y); //新横线 My.DrawLine(NewPen,e.X,0,e.X,this.Size.Width); //新竖线 My.DrawLine(NewPen, 0, e.Y, this.Size.Width, e.Y); OldPoint = e.Location; } }}很简单的实现,只有一个窗口,如果有背景图就不能这样了! GDI 用异或笔话,原地重画即可擦除还原背景 cbbcard(波比) 这样的话移动之后不会擦除掉!! Winform中嵌入网页 C#如何传结构体给C++? for实现HashTable遍历 几道基础笔试题,大家各抒己见(重分酬谢) 不存在此行此列 求教簡單sql 关于SQL存储过程的怪问题,请大家帮忙! c#中用Formula one动态建表 求救,迷惑了很久的问题 用socket发送邮件如何验证? C#.net 中如何操纵access数据库(包括连接、增、删、改、查等) 多线程和异步调用的区别
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace WindowsApplication1
{
public partial class Form1 : Form
{
Point OldPoint;
Pen OldPen, NewPen;
public Form1()
{
InitializeComponent();
OldPoint = new Point(0, 0);
OldPen = new Pen(this.BackColor);
NewPen = new Pen(this.ForeColor);
} private void Form1_MouseMove(object sender, MouseEventArgs e)
{
Graphics My = this.CreateGraphics(); //旧横线
My.DrawLine(OldPen, OldPoint.X, 0, OldPoint.X, this.Size.Width);
//旧竖线
My.DrawLine(OldPen, 0, OldPoint.Y, this.Size.Width, OldPoint.Y);
//新横线
My.DrawLine(NewPen,e.X,0,e.X,this.Size.Width);
//新竖线
My.DrawLine(NewPen, 0, e.Y, this.Size.Width, e.Y);
OldPoint = e.Location; }
}
}
很简单的实现,只有一个窗口,如果有背景图就不能这样了!