title: Drawing a single line in different Color
body: <p>I am trying to draw a line which can be broken into different segments (in C# winforms).</p>
  
  <p>Each segment will then be of a different colour and also display a name on it.</p>
  
  <p>What I've done right now is:</p>
  
  <pre><code> int startXPosition = 100;
   int startYPosition = 50;
   int numSegment = 5;
   int endXPosition = startXPosition;
   int endYPosition = this.Height / numSegment;
  
   Pen blackPen = new Pen(Color.Black, 5);
   e.Graphics.DrawLine(blackPen, new       Point(startXPosition, startYPosition), new      Point(endXPosition, endYPosition));
  </code></pre>
  
  <p>This will allow me to draw a line base on the form's height / 5 (the number of segment) using black color.</p>
  
  <p>How do I continue from here such that I am able to draw the rest of the segment (4) in which it will be in different colour? </p>
  
  <p>How can i do it in such a way that I won't need to define the colour and the code can auto assign a color to each different segment?</p>