TextBox padding

  • Thread starter Thread starter Mark.Larsen
  • Start date Start date
M

Mark.Larsen

I'm still looking for a way to adjust the vertical
location of the text in a TextBox without overriding the
OnPaint. Any ideas?
 
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 (e-mail address removed).";
======== 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 (e-mail address removed).";
======== END code #2 in "Load" method =======
 
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.
 
Thanks. I had considered doing something like this if
there weren't any better answers.
 
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.
 
Back
Top