Format text Windows Forms

0

I have a system and I need to justify the text on the left, I already tried with the textbox and with ritchtext and neither of them give me this option, I can only align the left, but when I align only the first column of text is aligned, the others follow the alignment and mess, ideally I would justify the left because the columns would all align. : //i.stack.imgur.com/17tHO.jpg ">

    
asked by anonymous 12.08.2016 / 19:33

1 answer

2

You can do the following in the TextAlign property of TextBox you set to left .

When you fill in the TextBox already leave your string formatted, eg:

public static void Main()
{
  string[] names = { "Adam", "Bridgette", "Carla", "Daniel", "Ebenezer","Francine", "George" };
  decimal[] hours = { 40, 6.667m, 40.39m, 82, 40.333m, 80, 16.75m };

  Console.WriteLine("{0,-20} {1,5}\n", "Name", "Hours");

  for (int ctr = 0; ctr < names.Length; ctr++)
     Console.WriteLine("{0,-20} {1,5:N1}", names[ctr], hours[ctr]);

}

Result:

// The example displays the following output:
//       Name                 Hours
//
//       Adam                  40.0
//       Bridgette              6.7
//       Carla                 40.4
//       Daniel                82.0
//       Ebenezer              40.3
//       Francine              80.0
//       George                16.8

Source: Here

    
12.08.2016 / 21:12