我现在在做一个CE 项目, 里面设计到 一个列表滚动的问题
我的做法是这样的,
private void PB_mousemove(object sender, PaintEventArgs e)
{
Graphics g=pb.createGraphics(); g.DrawRectangle(new Pen(Color.Red,1.5F),new Rectangle(0,e.Y,200,200));}
就是在 mousemove 事件里捕获鼠标点,然后画, 可是当运行起来的时候发现
1。画面不流畅,
2。我按住鼠标移动的时候,并没有实时去绘制 我的矩形 请各位帮忙看,我要怎么解决? 在线等到
我的做法是这样的,
private void PB_mousemove(object sender, PaintEventArgs e)
{
Graphics g=pb.createGraphics(); g.DrawRectangle(new Pen(Color.Red,1.5F),new Rectangle(0,e.Y,200,200));}
就是在 mousemove 事件里捕获鼠标点,然后画, 可是当运行起来的时候发现
1。画面不流畅,
2。我按住鼠标移动的时候,并没有实时去绘制 我的矩形 请各位帮忙看,我要怎么解决? 在线等到
解决方案 »
- 异步 Socket how to ?
- C#编译的exe文件在别的机器上无法运行
- [求救]如何从网页中与本地应用程序交互
- 从数据库sql server 读取图片A generic error occurred in GDI+.错误
- vs2003 winform如何弹出一个让用户选择“是”、“否”的对话框,并取得用户的选择结果?
- 各位大侠请问 C#怎么将汉字转换成16进制啊?
- 实时数据显示问题
- winfrom里面的数据列表实现拖拽效果用什么控件
- 如何把check样式 修改成图片。
- 急问:如何使用C#编程列出当前可用的SQL server服务器
- 手机开发中,如何在picturebox在显示图片?
- 怎么才能使用GetCharABCWidths这个API函数
{
g.FillRectangle(blueBrush, new Rectangle(x, y, 165, 40));
g.DrawRectangle(penRectangle, new Rectangle(x, y, 165, 40));
g.DrawLine(penRectangle, x, y + 20, x + 165, y + 20);
g.DrawLine(penRectangle, x + 55, y, x + 55, y + 40);
g.DrawLine(penRectangle, x + 110, y, x + 110, y + 40);
g.DrawString("起始时间", new Font("黑体", 8), Brushes.Black, new Point(x + 3, y + 5));
g.DrawString(DateTime.Now.ToShortDateString(), new Font("宋体", 8), Brushes.Black, new Point(x + 3, y + 5 + 20));
g.DrawString("结束时间", new Font("黑体", 8), Brushes.Black, new Point(x + 3 + 55, y + 5));
g.DrawString(DateTime.Now.ToShortDateString(), new Font("宋体", 8), Brushes.Black, new Point(x + 3 + 55, y + 5 + 20));
g.DrawString("持续时间", new Font("黑体", 8), Brushes.Black, new Point(x + 3 + 110, y + 5));
g.DrawString("N天", new Font("黑体", 8), Brushes.Black, new Point(x + 13 + 110, y + 5 + 20));
}
public void DrawRectangle(Point p, Graphics g)
{
penRectangle.LineJoin = LineJoin.Round;
int x;
int y; if (p.X < 180)
{
if (p.Y < 60)
{
x = p.X + 20;
y = p.Y + 20;
DrawImage(x, y, g);
return;
}
x = p.X + 20;
y = p.Y - 60;
DrawImage(x, y, g); }
else if (p.Y < 60)
{
x = p.X - 20 - 159;
y = p.Y + 20;
DrawImage(x, y, g);
}
else
{
x = p.X - 20 - 159;
y = p.Y - 20 - 40;
DrawImage(x, y, g);
}
} private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
Graphics g = pictureBox1.CreateGraphics();
DrawRectangle(new Point(e.X, e.Y), pictureBox1.CreateGraphics());
}
希望对你有帮助!