title: Change Caret (Cursor) in Textbox in C#
body: <p>I want to change the Caret in a Textbox in C# that it appears wider like in does in old DOS applications. </p>
  
  <p>What i have: <a href="https://i.stack.imgur.com/AO2QR.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AO2QR.jpg" alt="enter image description here"></a></p>
  
  <p>Example what i want:
  <a href="https://i.stack.imgur.com/iMzzn.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iMzzn.jpg" alt="enter image description here"></a></p>
  
  <p>I tried:</p>
  
  <pre><code>using System.Runtime.InteropServices;
  </code></pre>
  
  <p>...</p>
  
  <pre><code>  [DllImport("user32.dll")]
    static extern bool CreateCaret(IntPtr hWnd, IntPtr hBitmap, int nWidth, int nHeight);
    [DllImport("user32.dll")]
    static extern bool ShowCaret(IntPtr hWnd);
  </code></pre>
  
  <p>...</p>
  
  <pre><code>public partial class Form1 : Form
  {
      [DllImport("user32.dll")]
      static extern bool CreateCaret(IntPtr hWnd, IntPtr hBitmap, int nWidth, int nHeight);
      [DllImport("user32.dll")]
      static extern bool ShowCaret(IntPtr hWnd);
  
      public Form1()
      {
          InitializeComponent();
      }
  
      private void Form1_Shown(object sender, EventArgs e)
      {
          CreateCaret(textBox1.Handle, IntPtr.Zero, 20, textBox1.Height);
          ShowCaret(textBox1.Handle);
      }
  }
  </code></pre>
  
  <p>But it still looks the same. Any help would be nice. Thanks in advance!</p>
  
  <p>Edit:</p>
  
  <p>This was just an example. My real code looks like:</p>
  
  <pre><code>TextBox textbox = new TextBox();
   textbox.MaxLength = fieldLength;
   textbox.Width = fieldLength*24;
   textbox.MaxLength = maxChars;
   this.Controls.Add(textbox);
  
   CreateCaret(textbox.Handle, IntPtr.Zero, 20, textbox.Height);
   ShowCaret(textbox.Handle);
  </code></pre>
  
  <p>The code gets called but doesnt change anything.</p>
  
  <p>Edit2: </p>
  
  <p>I tried the example and it works fine but my problem still exisits:
  I cant change the Caret when creating the textbox. Its only possible for a textbox created with the form.</p>