WhiteSpaces & Strings

G

Guest

Hi

Have a method that builds and returns a of specfic accounting codes to a
datagrid textbox field.

eg, if a user types in "200" the method builds & returns the code "200.00.00".

also if a user types in "51" the method should return " 51.00.00" but I am
finding difficulty adding a white space infront of the string, I have been
using the PadLeft method eg: sCode = sCode.PadLeft(1, ' ') + ".00" + ".00";
but with no success.
Even if I add a whitespace to the Datagridtextbox it removes it.

So my question is, is it possible to add whitespaces infront of the string?
and
Is it possible to format the textbox so it can leading spaces?
If anyone has any examples that would be great.

thanks
Dave
 
C

Chris R. Timmons

Hi

Have a method that builds and returns a of specfic accounting
codes to a datagrid textbox field.

eg, if a user types in "200" the method builds & returns the
code "200.00.00".

also if a user types in "51" the method should return "
51.00.00" but I am finding difficulty adding a white space
infront of the string, I have been using the PadLeft method eg:
sCode = sCode.PadLeft(1, ' ') + ".00" + ".00"; but with no
success. Even if I add a whitespace to the Datagridtextbox it
removes it.

So my question is, is it possible to add whitespaces infront of
the string? and
Is it possible to format the textbox so it can leading spaces?
If anyone has any examples that would be great.

Dave,

If you want the first set of digits to be three characters wide, use
PadLeft(3, ' '). The "3" tells PadLeft the total width of the
string, not how many spaces it should add.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top