?
Solved

How to autosize a textbox?

Posted on 2011-09-07
5
Medium Priority
?
429 Views
Last Modified: 2013-12-17
Hi,

I have a dialogform with just a textbox on it.
The textbox is set to dock=top and size.height
set to 13.

Every time I put a line of text into the textbox
then every line on top disappears.

How can I make the textbox autosize to its text?

Greetings,

Peter Kiers
0
Comment
Question by:peterkiers
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 2000 total points
ID: 36495155
Are you appending the text to the existing text or overwriting the text with new text ?

You can test simply by using the arrow keys when the cursor is in the text box.
ps.  You might need to have the textbox property - multiline - set to true.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 36495161
0
 
LVL 1

Author Comment

by:peterkiers
ID: 36495187
I have a panel with 2 textboxes on it. textBox1 is set to dock=top and textBox2 is set to dock=fill.
I have set this event for textBox1:

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
            {
                textBox2.Focus();

            }
        }

So the cursor goes from textBox1 to textBox2 after pressing the return-button.
But I want when the user starts typing in textBox1 and it reaches the end of the line
it then have to go to the nextline of the textBox1. And it doesn't.
How can I fixe this?

Peter
0
 
LVL 16

Expert Comment

by:Easwaran Paramasivam
ID: 36495216
Keep your textboxes as Multiline text box where it accepts more than one line as input. Your code moves the focus to next textbox. This is contrary with your requirement. Remove it.
0
 
LVL 1

Author Comment

by:peterkiers
ID: 36495254
Both are set to MultiLine = true.
And I need the code because when the user presses enter in textBox1
it have to go to textbox2. Just the way I wanted.
Only in textbox1 the line of text has to go one to the second line
when the end of the textbox is reached.

Peter
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question