title: Drawing a rectangle inside every textbox c# winform
body: <p>I want to differentiate the obligatory TextBox fields in my forms. I was achieving this by creating a class with a method called by every form. What that method does, is receive a list of textbox and for each one, it sets the backcolor to another.</p>
  
  <pre><code>public static void Mostrar_campos_obligatorios(List&lt;TextBox&gt; lista_textbox)
  {
      foreach (TextBox tbx in lista_textbox)
      {
          tbx.Paint += new PaintEventHandler(TextBoxRectangle);
      }
  }
  </code></pre>
  
  <p>I have changed the GUI now, and I dont like how it looks like when the backcolor is changed, then I wanted to draw a rectangle as I show in the next picture:</p>
  
  <p><img src="https://i.stack.imgur.com/B5kMi.png" alt="enter image description here"></p>
  
  <p>Leave to me the gradient stuff, I just need help to draw a rectangle of the same height of each TextBox and to be located at the end of it. I want to use that method definition too (I mean, to receive a list of textboxes).</p>
  
  <p>Notice that the methods are static..</p>
  
  <p>I tried something like this:</p>
  
  <pre><code>public static void TextBoxRectangle(object sender, PaintEventArgs e)
  {
      tbx = (TextBox)sender;
      Color c1 = Color.FromArgb(255, 113, 255, 0);
      Color c2 = Color.FromArgb(255, 2, 143, 17);
  
      LinearGradientBrush br = new LinearGradientBrush(e.CellBounds, c1, c2, 90, true);
  
      ColorBlend cb = new ColorBlend();
      cb.Positions = new[] { 0, (float)1 };
      cb.Colors = new[] { c1, c2 };
  
      br.InterpolationColors = cb;
  
      Rectangle rect = new Rectangle(tbx.Location.X + 4, tbx.Location.Y + 4, 13, 13);
  
      e.Graphics.FillRectangle(br, rect);
  }
  </code></pre>
  
  <p>But is not working. It´s don´t even access the <code>TextBoxRectangle()</code>. I think I´m doing it very wrong..</p>