Solved

How to autosize a textbox?

Posted on 2011-09-07
5
405 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
5 Comments
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
c# code 19 61
ConsoleSql 1 18
Long URL in SMS 6 24
Copy/Clone an object. 9 15
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now