title: Button inside a winforms textbox vb.net
body: <p>i`m vb.net programmer and i found solution for my problem but in c# on this address: <a href="https://stackoverflow.com/questions/15868817/button-inside-a-winforms-textbox">Button inside a winforms textbox</a> </p>
  
  <p>I have converted code to vb.net and it works good except text goes underneath the button here is my converted and c# code, pls tell me where i`m wrong</p>
  
  <p>C# CODE</p>
  
  <pre><code>    protected override void OnLoad(EventArgs e) {
      var btn = new Button();
      btn.Size = new Size(25, textBox1.ClientSize.Height + 2);
      btn.Location = new Point(textBox1.ClientSize.Width - btn.Width, -1);
      btn.Cursor = Cursors.Default;
      btn.Image = Properties.Resources.star;
      textBox1.Controls.Add(btn);
      // Send EM_SETMARGINS to prevent text from disappearing underneath the button
      SendMessage(textBox1.Handle, 0xd3, (IntPtr)2, (IntPtr)(btn.Width &lt;&lt; 16));
      base.OnLoad(e);  
  }
  
  [System.Runtime.InteropServices.DllImport("user32.dll")]
  private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);
  </code></pre>
  
  <p>My VB.NET CODE</p>
  
  <pre><code>     btn.Size = New Size(25, Me.ClientSize.Height + 2)
       btn.Location = New Point(Me.ClientSize.Width - btn.Width - 1)
       btn.FlatStyle = FlatStyle.Flat
       btn.Cursor = Cursors.Default
       btn.Image = Image.FromFile("C:\ansoft\Soljica\texture\tone.png")
       btn.FlatAppearance.BorderSize = 0
       textbox1.Controls.Add(btn)
       SendMessage(textbox1.Handle, &amp;HED3, CType(2, IntPtr), CType((btn.Width &lt;&lt; 16), IntPtr))
  
  
  &lt;System.Runtime.InteropServices.DllImport("user32.dll")&gt; _
  Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wp As IntPtr, ByVal lp As IntPtr) As IntPtr
  End Function
  </code></pre>
  
  <p>What is wrong with vb.net code if anyone can tell me pls ?</p>
  
  <p>For c# code credits goes to: Hans Passant</p>