The simpliest solution by using the native components would be implementing you own custom-control using the textbox
and adding MouseEvents
. Here is a sample that lets you drag the TextBox
's bottom area, in vertical direction. Of course you should implement something more like changing the cursor's handle and repainting some areas if you would like to make a pop-up
.
Here is a working concept:
bool isDrag = false;
int lastY = 0;
private void textBox1_MouseEnter(object sender, EventArgs e)
{
//Change cursor to dragging handle or implement a pop-up
}
private void textBox1_MouseDown(object sender, MouseEventArgs e)
{
//Just add 5px padding
if (e.Y >= (textBox1.ClientRectangle.Bottom - 5) &&
e.Y <= (textBox1.ClientRectangle.Bottom + 5))
{
isDrag = true;
lastY = e.Y;
}
}
private void textBox1_MouseMove(object sender, MouseEventArgs e)
{
if( isDrag)
{
textBox1.Height += (e.Y - lastY);
lastY = e.Y;
}
}
private void textBox1_MouseUp(object sender, MouseEventArgs e)
{
if (isDrag)
{
isDrag = false;
}
}
To try the code, on a new form, create a TextBox
named textBox1
and wire all the MouseEvents
. Try to bring your mouse on the bottom of the TextBox
and drag either going top or bottom.
And do not forget to set TextBox.Multiline
to true
.