473,402 Members | 2,053 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,402 software developers and data experts.

Multline TextBox question

I have a multiline textbox.

The size of the text box should be 75 characters wide, and 5 lines in
height like this: -

<---75 characters-->
<---75 characters-->
<---75 characters-->
<---75 characters-->
<---75 characters-->

I have used maxlength to limit the characters to 375 (75 X 5).

My question is how to I specify the layout of the textbox to be 75
characters wide and 5 lines in height. The only size property i can see
takes a value in pixels, which isn't suitable here.

Thankyou,

Gary.

Jan 4 '07 #1
10 2430

ga********@myway.com wrote:
My question is how to I specify the layout of the textbox to be 75
characters wide and 5 lines in height. The only size property i can see
takes a value in pixels, which isn't suitable here.
There are Columns and Rows properties.

Jan 4 '07 #2
There are? They don't display in the property pane, and when i try to
access them programmatically using textbox.Columns or textbox.Rows they
aren't accessible either?

Can you tell me how I access these properties?

Thanks,

Gary.

marss wrote:
ga********@myway.com wrote:
My question is how to I specify the layout of the textbox to be 75
characters wide and 5 lines in height. The only size property i can see
takes a value in pixels, which isn't suitable here.

There are Columns and Rows properties.
Jan 4 '07 #3

ga********@myway.com wrote:
There are? They don't display in the property pane, and when i try to
access them programmatically using textbox.Columns or textbox.Rows they
aren't accessible either?

Can you tell me how I access these properties?

Thanks,

Gary.
If you writing Web Application :
http://msdn2.microsoft.com/en-us/lib...x.columns.aspx
http://msdn2.microsoft.com/en-us/lib...tbox.rows.aspx

But now I guess you write Win Application. :(

Jan 4 '07 #4
yes writing windows form application =(
marss wrote:
ga********@myway.com wrote:
There are? They don't display in the property pane, and when i try to
access them programmatically using textbox.Columns or textbox.Rows they
aren't accessible either?

Can you tell me how I access these properties?

Thanks,

Gary.

If you writing Web Application :
http://msdn2.microsoft.com/en-us/lib...x.columns.aspx
http://msdn2.microsoft.com/en-us/lib...tbox.rows.aspx

But now I guess you write Win Application. :(
Jan 4 '07 #5

ga********@myway.com wrote:
yes writing windows form application =(
Sorry for silly question.
Why don't you want to enter text in textbox in design time: 5 rows,
every with 75 characters, resize textbox to fit all characters and
remove entered text?

Jan 4 '07 #6
Thankyou marss that's a good idea. I have now populated the textbox
with sample text at runtime. How do i tell the textbox to resize to fit
this text, i can't find a resize method or anything simmilar, thanks...
Gary.

marss wrote:
ga********@myway.com wrote:
yes writing windows form application =(

Sorry for silly question.
Why don't you want to enter text in textbox in design time: 5 rows,
every with 75 characters, resize textbox to fit all characters and
remove entered text?
Jan 4 '07 #7
Hi Gary,

You can get an approximation using the Graphics.MeasureString method (GDI+)
or TextRenderer.MeasureText method (GDI; 2.0 framework only). Simply call
CreateGraphics on the TextBox and pass the Graphics object to one of the
Measure* methods along with the specific text and Font.

If the Font isn't fixed-width then you should probably specify 375 upper
case "M" characters as the text to ensure maximum coverage for the
calculation. Otherwise, 375 of any printable character will do for a
fixed-width font.

Note: Don't be tempted to draw to the Graphics object retrieved from the
CreateGraphics method and don't forget to dispose of it after the text is
measured.

--
Dave Sexton
http://davesexton.com/blog

<ga********@myway.comwrote in message
news:11*********************@11g2000cwr.googlegrou ps.com...
>I have a multiline textbox.

The size of the text box should be 75 characters wide, and 5 lines in
height like this: -

<---75 characters-->
<---75 characters-->
<---75 characters-->
<---75 characters-->
<---75 characters-->

I have used maxlength to limit the characters to 375 (75 X 5).

My question is how to I specify the layout of the textbox to be 75
characters wide and 5 lines in height. The only size property i can see
takes a value in pixels, which isn't suitable here.

Thankyou,

Gary.

Jan 4 '07 #8
Thankyou Dave. I will look at that. But I can't help thinking i've
asked the wrong question.
Perhaps I'll try again maybe someone can offer a solution.

My textbox takes text data from the user and then copies this to the
clipboard. I then switch to another application and paste this data
from the clipboard into the other application. The application
receiving the text demands that the text cover no more than 5 lines,
each line consisting of no more than 75 characters.

The reason I was trying to resize the textbox was so that it looked the
same as it would look when it is pasted into this second programme.

But I realise now I need some way of enforcing that each line contains
only 75 characters, because even if I managed to size the textbox
exactly to 5x75 character lines, there is nothing stopping the user
from actually entering 1x375 line into this textbox. If i can find a
way of enoforcing that each line in the textbox has a maximum size of
75 characters I think this in itself will take care of the text being
displayed as it will look in the target application once it is pasted.

Any idea how I do this with the standard multiline textbox?

I was considering just creating 5 seperate text box, and playing around
with their events to try to make them act as one text box, do you think
this will be a better approach?

Thankyou Experts,

Gary.
Dave Sexton wrote:
Hi Gary,

You can get an approximation using the Graphics.MeasureString method (GDI+)
or TextRenderer.MeasureText method (GDI; 2.0 framework only). Simply call
CreateGraphics on the TextBox and pass the Graphics object to one of the
Measure* methods along with the specific text and Font.

If the Font isn't fixed-width then you should probably specify 375 upper
case "M" characters as the text to ensure maximum coverage for the
calculation. Otherwise, 375 of any printable character will do for a
fixed-width font.

Note: Don't be tempted to draw to the Graphics object retrieved from the
CreateGraphics method and don't forget to dispose of it after the text is
measured.

--
Dave Sexton
http://davesexton.com/blog

<ga********@myway.comwrote in message
news:11*********************@11g2000cwr.googlegrou ps.com...
I have a multiline textbox.

The size of the text box should be 75 characters wide, and 5 lines in
height like this: -

<---75 characters-->
<---75 characters-->
<---75 characters-->
<---75 characters-->
<---75 characters-->

I have used maxlength to limit the characters to 375 (75 X 5).

My question is how to I specify the layout of the textbox to be 75
characters wide and 5 lines in height. The only size property i can see
takes a value in pixels, which isn't suitable here.

Thankyou,

Gary.
Jan 5 '07 #9
Hi Gary,

That's a very difficult request. I tried to create a simple Multiline
solution or multiple TextBox solution but there are just too many things to
consider.

In either case if you want to try it by handling the KeyDown event, for
instance, then you'll have to consider placement of the text cursor, length
of the selection, keys such as Delete, Backspace, Enter, the control keys
and undo, cut, copy and paste (Ctrl+Z, Ctrl+X, Ctrl+C and Ctrl+V,
respectively). Anything less and end-users might be surprised by the
behavior of your TextBox, considering it buggy.

--
Dave Sexton
http://davesexton.com/blog

<ga********@myway.comwrote in message
news:11**********************@51g2000cwl.googlegro ups.com...
Thankyou Dave. I will look at that. But I can't help thinking i've
asked the wrong question.
Perhaps I'll try again maybe someone can offer a solution.

My textbox takes text data from the user and then copies this to the
clipboard. I then switch to another application and paste this data
from the clipboard into the other application. The application
receiving the text demands that the text cover no more than 5 lines,
each line consisting of no more than 75 characters.

The reason I was trying to resize the textbox was so that it looked the
same as it would look when it is pasted into this second programme.

But I realise now I need some way of enforcing that each line contains
only 75 characters, because even if I managed to size the textbox
exactly to 5x75 character lines, there is nothing stopping the user
from actually entering 1x375 line into this textbox. If i can find a
way of enoforcing that each line in the textbox has a maximum size of
75 characters I think this in itself will take care of the text being
displayed as it will look in the target application once it is pasted.

Any idea how I do this with the standard multiline textbox?

I was considering just creating 5 seperate text box, and playing around
with their events to try to make them act as one text box, do you think
this will be a better approach?

Thankyou Experts,

Gary.
Dave Sexton wrote:
>Hi Gary,

You can get an approximation using the Graphics.MeasureString method
(GDI+)
or TextRenderer.MeasureText method (GDI; 2.0 framework only). Simply
call
CreateGraphics on the TextBox and pass the Graphics object to one of the
Measure* methods along with the specific text and Font.

If the Font isn't fixed-width then you should probably specify 375 upper
case "M" characters as the text to ensure maximum coverage for the
calculation. Otherwise, 375 of any printable character will do for a
fixed-width font.

Note: Don't be tempted to draw to the Graphics object retrieved from the
CreateGraphics method and don't forget to dispose of it after the text is
measured.

--
Dave Sexton
http://davesexton.com/blog

<ga********@myway.comwrote in message
news:11*********************@11g2000cwr.googlegro ups.com...
>I have a multiline textbox.

The size of the text box should be 75 characters wide, and 5 lines in
height like this: -

<---75 characters-->
<---75 characters-->
<---75 characters-->
<---75 characters-->
<---75 characters-->

I have used maxlength to limit the characters to 375 (75 X 5).

My question is how to I specify the layout of the textbox to be 75
characters wide and 5 lines in height. The only size property i can see
takes a value in pixels, which isn't suitable here.

Thankyou,

Gary.

Jan 5 '07 #10
Ah i see what you mean. OK well I'll move on from that for now. The
project is a hobby project of mine, so I can do with the box being a
little buggy for now I guess! So will go with the five indiviudal text
box controls. And maybe in a year or so when i'm more advanced I can
write my own custom control for it!

Thanks again for your kind time and thought i'd be lost without it!

Gary-

Dave Sexton wrote:
Hi Gary,

That's a very difficult request. I tried to create a simple Multiline
solution or multiple TextBox solution but there are just too many things to
consider.

In either case if you want to try it by handling the KeyDown event, for
instance, then you'll have to consider placement of the text cursor, length
of the selection, keys such as Delete, Backspace, Enter, the control keys
and undo, cut, copy and paste (Ctrl+Z, Ctrl+X, Ctrl+C and Ctrl+V,
respectively). Anything less and end-users might be surprised by the
behavior of your TextBox, considering it buggy.

--
Dave Sexton
http://davesexton.com/blog

<ga********@myway.comwrote in message
news:11**********************@51g2000cwl.googlegro ups.com...
Thankyou Dave. I will look at that. But I can't help thinking i've
asked the wrong question.
Perhaps I'll try again maybe someone can offer a solution.

My textbox takes text data from the user and then copies this to the
clipboard. I then switch to another application and paste this data
from the clipboard into the other application. The application
receiving the text demands that the text cover no more than 5 lines,
each line consisting of no more than 75 characters.

The reason I was trying to resize the textbox was so that it looked the
same as it would look when it is pasted into this second programme.

But I realise now I need some way of enforcing that each line contains
only 75 characters, because even if I managed to size the textbox
exactly to 5x75 character lines, there is nothing stopping the user
from actually entering 1x375 line into this textbox. If i can find a
way of enoforcing that each line in the textbox has a maximum size of
75 characters I think this in itself will take care of the text being
displayed as it will look in the target application once it is pasted.

Any idea how I do this with the standard multiline textbox?

I was considering just creating 5 seperate text box, and playing around
with their events to try to make them act as one text box, do you think
this will be a better approach?

Thankyou Experts,

Gary.
Dave Sexton wrote:
Hi Gary,

You can get an approximation using the Graphics.MeasureString method
(GDI+)
or TextRenderer.MeasureText method (GDI; 2.0 framework only). Simply
call
CreateGraphics on the TextBox and pass the Graphics object to one of the
Measure* methods along with the specific text and Font.

If the Font isn't fixed-width then you should probably specify 375 upper
case "M" characters as the text to ensure maximum coverage for the
calculation. Otherwise, 375 of any printable character will do for a
fixed-width font.

Note: Don't be tempted to draw to the Graphics object retrieved from the
CreateGraphics method and don't forget to dispose of it after the text is
measured.

--
Dave Sexton
http://davesexton.com/blog

<ga********@myway.comwrote in message
news:11*********************@11g2000cwr.googlegrou ps.com...
I have a multiline textbox.

The size of the text box should be 75 characters wide, and 5 lines in
height like this: -

<---75 characters-->
<---75 characters-->
<---75 characters-->
<---75 characters-->
<---75 characters-->

I have used maxlength to limit the characters to 375 (75 X 5).

My question is how to I specify the layout of the textbox to be 75
characters wide and 5 lines in height. The only size property i can see
takes a value in pixels, which isn't suitable here.

Thankyou,

Gary.
Jan 5 '07 #11

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

Similar topics

2
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when...
2
by: Devinim ÞÖLEN | last post by:
Hi; I try to fetch data and show in the textbox as follows; .. .. .. .. <asp:XmlDataSource Id="m_ChXmlDataSource" runat="server"...
3
by: Henry | last post by:
Hi. I've also posted this at another discussion board and here is the original question. ------------------------- "I have this problem and I don't know what I can do. First of all, I have a...
2
by: Jon | last post by:
Hello All, I have a datalist whose itemtemplate contains a label and a textbox. The label text is set on itemdatabound with the text, which is a question, from the database column. Each question...
0
by: jason | last post by:
Hello everyone. I am trying to write some custom command events into a DataGrid. The command that is currently giving me trouble is an "Add" custom command in the footer of a template column. ...
4
by: Agnes | last post by:
How can I limit the line for the user to input in the "multiline - textbox ?" Thanks a lot. From Agnes
1
by: melanieab | last post by:
Hi, If there's a textbox and the text entered is longer than what's visible (the textbox length), how do you make it so that the beginning chunk of text is visible (instead of the last part of...
13
by: WALDO | last post by:
I have a .Net TextBox (TextBoxBase, really) in which I am appending about 20 lines of text per second. I use the AppendText() method to accomplish this. This is a great substitute for taking the...
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' &...
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: 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?
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.