468,136 Members | 1,466 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,136 developers. It's quick & easy.

TextBox padding

I'm still looking for a way to adjust the vertical
location of the text in a TextBox without overriding the
OnPaint. Any ideas?
Nov 15 '05 #1
4 13749
Mark,

Not sure if this is the kind of thing you mean, but:

1st set up a "Load" notification event for your parent
form (just double-click on the form, or do it manually
under events).

2nd, under the code for the "Load" method add the text in
the form that you want. This is an example of text that
I used copied from one of my programs (so ignore what it
says & just look at the spacing). I gave you two
different ways to enter text. I have the text
box's 'WordWrap' set to 'True' & 'ScrollBars' set
to 'vertical'. Hopefully this is the kind of thing your
were after.

======== BEGIN code #1 in "Load" method =======
this.textBox1.Clear();
this.textBox1.Text = @"After choosing a general 'System
of Units', then choose 'Custom' to change units
individually.

SI - International Standard for Metric Units.
SPE - Society of Petroleum Engineers Metric
Standard, June 1984 (www.spe.org).

Standards noted by {SI} and {SPE} are for general
guidance only. Standards often change depending on usage,
quantities, etc.

To include other units not shown, contact FSEG at 505-792-
1412 or cs****@attglobal.net.";
======== END code #1 in "Load" method =======

======== BEGIN code #2 in "Load" method =======
this.textBox1.Text = "After choosing a general 'System of
Units', then choose 'Custom' to change units
individually."+
"\r\n\r\nSI - International Standard for Metric Units."+
"\r\nSPE - Society of Petroleum Engineers Metric"+
"\r\n Standard, June 1984 (www.spe.org)."+
"\r\n\r\nStandards noted by {SI} and {SPE} are for
general guidance only. Standards often change depending
on usage, quantities, etc."+
"\r\n\r\nTo include other units not shown, contact FSEG
at 505-792-1412 or cs****@attglobal.net.";
======== END code #2 in "Load" method =======
-----Original Message-----
I'm still looking for a way to adjust the vertical
location of the text in a TextBox without overriding the
OnPaint. Any ideas?
.

Nov 15 '05 #2
1) you could create your own control. Add an outer panel1 to the control.
The control rectangle will size around this panel1 (panel1 will fill the
rectangle.) The panel will also handle things like border sytle to give you
your 3d border, etc. Now add a textbox (no border) inside the panel and
position it or add another panel (panel2) and put your textbox inside of it.
You can then pos panel2 anywhere inside panel1 to give you the vertical
space you need. The textbox can just fill panel2. You need to size
everthing and resize if the font changes, but this works as I have done this
before.

--
William Stacey, MVP

"Ma*********@hill.af.mil" <an*******@discussions.microsoft.com> wrote in
message news:0e****************************@phx.gbl...
I'm still looking for a way to adjust the vertical
location of the text in a TextBox without overriding the
OnPaint. Any ideas?

Nov 15 '05 #3
Thanks. I had considered doing something like this if
there weren't any better answers.
-----Original Message-----
1) you could create your own control. Add an outer panel1 to the control.The control rectangle will size around this panel1 (panel1 will fill therectangle.) The panel will also handle things like border sytle to give youyour 3d border, etc. Now add a textbox (no border) inside the panel andposition it or add another panel (panel2) and put your textbox inside of it.You can then pos panel2 anywhere inside panel1 to give you the verticalspace you need. The textbox can just fill panel2. You need to sizeeverthing and resize if the font changes, but this works as I have done thisbefore.

--
William Stacey, MVP

"Ma*********@hill.af.mil" <an*******@discussions.microsoft.com> wrote inmessage news:0e****************************@phx.gbl...
I'm still looking for a way to adjust the vertical
location of the text in a TextBox without overriding the OnPaint. Any ideas?

.

Nov 15 '05 #4
If you find one, please let me know. I had to do this myself to get around
an issue when you make the border 3D. It makes the text 1pic too close to
the top, so I had to use this method as I could not find a better way. All
ears however.
--
William Stacey, MVP

"Ma*********@hill.af.mil" <an*******@discussions.microsoft.com> wrote in
message news:07****************************@phx.gbl...
Thanks. I had considered doing something like this if
there weren't any better answers.
-----Original Message-----
1) you could create your own control. Add an outer

panel1 to the control.
The control rectangle will size around this panel1

(panel1 will fill the
rectangle.) The panel will also handle things like

border sytle to give you
your 3d border, etc. Now add a textbox (no border)

inside the panel and
position it or add another panel (panel2) and put your

textbox inside of it.
You can then pos panel2 anywhere inside panel1 to give

you the vertical
space you need. The textbox can just fill panel2. You

need to size
everthing and resize if the font changes, but this works

as I have done this
before.

--
William Stacey, MVP

"Ma*********@hill.af.mil"

<an*******@discussions.microsoft.com> wrote in
message news:0e****************************@phx.gbl...
I'm still looking for a way to adjust the vertical
location of the text in a TextBox without overriding the OnPaint. Any ideas?

.

Nov 15 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Alex | last post: by
reply views Thread by Mark.Larsen | last post: by
4 posts views Thread by Rodrigo DeJuana | last post: by
8 posts views Thread by tshad | last post: by
8 posts views Thread by Filipe Marcelino | last post: by
10 posts views Thread by Per W. | last post: by
12 posts views Thread by =?Utf-8?B?anAybXNmdA==?= | last post: by
27 posts views Thread by didacticone | last post: by
1 post views Thread by gcdp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.