> Hi!
>
[quoted text clipped - 19 lines]
>
> How to make that all columns are alligned?
There are not alligned in the "corrected" example to begin with.
In any case you will have to do it manually, I know of no provider
that does this formatting (fixed length fields).
It's very easy in fact, all you have to do is pritn the field value,
and pad it with white spaces ( [size of the field] - [size of the
actual value] ). Of course you have to check for overflow.
Joza - 03 Apr 2008 23:01 GMT
> There are not alligned in the "corrected" example to begin with.
> In any case you will have to do it manually, I know of no provider
> that does this formatting (fixed length fields).
> It's very easy in fact, all you have to do is pritn the field value,
> and pad it with white spaces ( [size of the field] - [size of the
> actual value] ). Of course you have to check for overflow.
I try like this:
string var="";
string txt1 = "ABCD";
string txt2 = "EFGHIJK";
string num1 = "2.4";
string num2 = "6.5";
int myFieldSize = 35;
Console.WriteLine(txt1 + var.PadRight(myFieldSize - num1.Length) + num1);
Console.WriteLine(txt2 + var.PadRight(myFieldSize - num2.Length) + num2);
And the result is something like:
ABCD 2.4
EFGHIJK 6.5
instead of
ABCD 2.4
EFGHIJK 6.5
I just don't get it... :(
Joza - 03 Apr 2008 23:02 GMT
> There are not alligned in the "corrected" example to begin with.
> In any case you will have to do it manually, I know of no provider
> that does this formatting (fixed length fields).
> It's very easy in fact, all you have to do is pritn the field value,
> and pad it with white spaces ( [size of the field] - [size of the
> actual value] ). Of course you have to check for overflow.
I try like this:
string var="";
string txt1 = "ABCD";
string txt2 = "EFGHIJK";
string num1 = "2.4";
string num2 = "6.5";
int myFieldSize = 35;
Console.WriteLine(txt1 + var.PadRight(myFieldSize - num1.Length) + num1);
Console.WriteLine(txt2 + var.PadRight(myFieldSize - num2.Length) + num2);
And the result is something like:
ABCD 2.4
EFGHIJK 6.5
instead of
ABCD 2.4
EFGHIJK 6.5
I just don't get it... :(
Claes Bergefall - 04 Apr 2008 10:27 GMT
>> There are not alligned in the "corrected" example to begin with.
>> In any case you will have to do it manually, I know of no provider
[quoted text clipped - 14 lines]
> Console.WriteLine(txt1 + var.PadRight(myFieldSize - num1.Length) + num1);
> Console.WriteLine(txt2 + var.PadRight(myFieldSize - num2.Length) + num2);
You need to use the first column when calculating how much padding to add,
i.e.:
Console.WriteLine(txt1 + var.PadRight(myFieldSize - txt1.Length) + num1);
Console.WriteLine(txt2 + var.PadRight(myFieldSize - txt2.Length) + num2);
Also note that this will only align correctly if you view it using a
fixed-width font
/claes