473,386 Members | 1,721 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,386 software developers and data experts.

Textbox Problem

Hi NG,

I want to pass a very long string to a multilined TextBox. After doing this,
I want to resize the TextBox vertically, so that the text fits into the
TextBox exactly. Any ideas? I need it for a custom MessageBox.

Thank you

Rudi
Nov 15 '05 #1
2 1294
Hi,

I do not understand clearly what you are trying to do, but I can give you a
few suggestion, first of all, if it's for a MessageBox you should use a
Label instead of a TextBox , use the TextBox only if the user can change the
Text.
You can format the text of the message, I remember I did that once in
javascript you could insert \n at certain points to force a correct display
of the message, later you can know how many lines the message has by
counting the \n.

Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"DotNetJunkie" <do**********@gmx.net> wrote in message
news:Ol**************@TK2MSFTNGP12.phx.gbl...
Hi NG,

I want to pass a very long string to a multilined TextBox. After doing this, I want to resize the TextBox vertically, so that the text fits into the
TextBox exactly. Any ideas? I need it for a custom MessageBox.

Thank you

Rudi

Nov 15 '05 #2
Rudi,

I think that the calculation for this might not be so simple. You can probably call the MeasureString method on the Graphics class, and then check to see how many lines you will need based on the length of your text (you can approximate based on the number of pixels long, and all fonts have a consistent height). However, this is not exact. If you want to be exact, then you need to have an algorithm that will separate the words and see how many you can fit on each line, and then figure out how many lines you need based on the words.

Hope this helps.

-Nicholas Paldino [.NET/C# MVP]
-nick{dot]paldino=at^exisconsulting-dot?com

On Thu, 25 Sep 2003 20:26:57 +0200, DotNetJunkie <do**********@gmx.net> wrote:
Hi NG,

I want to pass a very long string to a multilined TextBox. After doing this,
I want to resize the TextBox vertically, so that the text fits into the
TextBox exactly. Any ideas? I need it for a custom MessageBox.

Thank you

Rudi

Nov 15 '05 #3

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

Similar topics

2
by: Jesper | last post by:
Last week I posted this for the first time. However, I didn't get any useable solution to my problem. I'm very keen on getting this problem solved, so please excuse me for trying again. I'll try to...
7
by: Joel Finkel | last post by:
Folks, I have a form that has several TextBoxes, some of which have the TextMode set to MultiLine. Each is pre-loaded with data from a database. The user is allowed to modify each entry. The...
7
by: Peter D.C. | last post by:
Hi I want to update data hold in several textbox controls on an asp.net form. But it seems like it is the old textbox values that is "re-updates" through a stored procedure who updates a SQL...
8
by: tshad | last post by:
I cannot seem to get the asp:textbox to use classes. Style works fine. I am trying to set the textbox to act like a label in some instance so it doesn't have a border, readonly and the background...
3
by: Brad Rogers | last post by:
All, Being immersed in vb.net and trying CSharp after almost a year I forgot the differences. I like vb fixing the uppercase/lowercase names and seeming to be more flexible to code entry. ...
8
by: Filipe Marcelino | last post by:
Hi, I'm trying to create a textbox inheriting from the standard textbox. I would like to: 1. repaint the textbox border; 2. define a color for that border; Till now I made this:
1
by: rn5a | last post by:
I want to create a custom control that encapsulates a Button & a TextBox. When the Button is clicked, the user is asked a question using JavaScript confirm (which shows 2 buttons - 'OK' &...
4
by: =?Utf-8?B?UmVuYXVkIExhbmdpcw==?= | last post by:
Hello, I have a strange yet very simple problem with the asp.net Textbox web control. On an empty asp.net page, add a single asp:TextBox control with Autopostback=false with nothing else on...
0
by: sjickells | last post by:
Hi I am having a problem using asp:TextBox's in a transparent table. I have a background image on the page and a table in the middle of the page. I have set the background colour of the table...
9
by: =?Utf-8?B?dHBhcmtzNjk=?= | last post by:
OK I have some Chinese text in sql server column that looks like this: 12大专题调研破解广东科学发展难题 This is unicode? Anyway, I put this data into a text area like this:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.