473,383 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Textbox Length

I need to set TextBox length based on the text length in the TextBox, so the
entire text in the box is visible. Can anyone point me to an info on how to
accomplish this?

Thank You
Peter

Feb 7 '06 #1
3 9980
Peter, try something like this:

using (Graphics g = textBox1.CreateGraphics())
{
SizeF s = g.MeasureString(textBox1.Text, textBox1.Font);
textBox1.Size = new Size((int) s.Width, (int) s.Height);
}

Hope it helps,
Thi

Feb 7 '06 #2

"Truong Hong Thi" <th*****@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Peter, try something like this:

using (Graphics g = textBox1.CreateGraphics())
{
SizeF s = g.MeasureString(textBox1.Text, textBox1.Font);
textBox1.Size = new Size((int) s.Width, (int) s.Height);
}

Hope it helps,
Thi


Thank You very much, this works
Feb 7 '06 #3
That's very helpful and instructive... thanks!
"Truong Hong Thi" <th*****@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Peter, try something like this:

using (Graphics g = textBox1.CreateGraphics())
{
SizeF s = g.MeasureString(textBox1.Text, textBox1.Font);
textBox1.Size = new Size((int) s.Width, (int) s.Height);
}

Hope it helps,
Thi

Feb 7 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Ramsin Savra | last post by:
Hi, What do you suggest to do if I want to do a search in TextBox ? I know that using RichTextBox, we could have Find method to search for a specific word or information but I was wonder if...
6
by: Stuart Ferguson | last post by:
Is there a way from a textbox that you can establish the maximum length of the text that will be displayed in the textbox on the screen. What i am not requring is the Max Length of the Textbox...
2
by: Peter | last post by:
I hate using the mask edit conrol so I created these two function to format my phone numbers. Is there a way to consolidate these two functions into one? In this example say the textbox you...
2
by: simon | last post by:
hello, new to vb.net, have a few questions about DataGrid. I have a dataGrid that is working pulling a dataset back from a stored proc and binding to the datagrid for display the datagrid's...
0
by: Anonieko | last post by:
Are there any javascript codes there? Answer: Yes On the PageLoad event call InitialClientControsl as follows /// <summary> /// This will add client-side event handlers for most of the...
8
by: nil | last post by:
Hello all, It's urgent... i want to add autocomplete textbox facility in my application like google. as you type it suggests option to the user..i want the same kind of facility...i know i...
0
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile...
1
by: rakeshnair | last post by:
i wrote a code in jsp to create dynamic table..the problem is i need data base connection when cursor moves from one cell to other... eg...when i enter product id in the first cell, the product name...
2
by: mrutyunjaya | last post by:
hello, i have two textbox column and one button control in gridvie when i click button it will ask plese enter price in first textbox . when enter values it is asking again. how to pass...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.