直接这样写 画出来的是直线。 
pen.DashStyle = DashStyle.Custom;
graphics.DrawLine(pen, point1, point2);怎么去自定义这个DashStyle.Custom呢?

解决方案 »

  1.   


    Graphics graphics(this->GetDC()->m_hDC); 
    Pen pen(Color(255, 0, 0, 0),1.f); 
    REAL dashVals[2] = {0.3f,5.0f }; pen.SetDashPattern(dashVals, 2); 
    pen.SetDashOffset(70); PointF p1(150, 400); 
    PointF p2(190, 400); 
    PointF p3(256, 310); 
    graphics.DrawLine(&pen,p1,p2 ); 
    graphics.DrawLine(&pen,p2,p3 ); 
      

  2.   

       Graphics _Graphcis = Graphics.FromHwnd(this.Handle);
                Pen _Pen = new Pen(Brushes.Yellow);
                _Pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom;
                _Pen.DashPattern = new float[] { 5f,10f };          
       
                _Graphcis.DrawLine(_Pen, 100,100, 200,100);