WhiteSpaces & Strings

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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.
 
Back
Top