我现在在做一个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。我按住鼠标移动的时候,并没有实时去绘制 我的矩形  请各位帮忙看,我要怎么解决? 在线等到

解决方案 »

  1.   

    public void DrawImage(int x, int y, Graphics g)
            {
                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());
            }
    希望对你有帮助!
      

  2.   

    我的要很简简, 大家在现在都用手机吧, 在手机列表显示条目的时候会有一个滚动的效果,当鼠标<触屏>移动的时候画面要上下翻动, 但是要保证其连惯性 
      

  3.   

    PB是什么?PictureBox?那画在bitmap上赋给PictureBox.Image啊
      

  4.   

    在MouseDown里记下按下时的点,在MouseMove里执行操作,在MouseUp里停止