How can I align text in columns using Console.WriteLine?

Try this Console.WriteLine(“{0,10}{1,10}{2,10}{3,10}{4,10}”, customer[DisplayPos], sales_figures[DisplayPos], fee_payable[DisplayPos], seventy_percent_value, thirty_percent_value); where the first number inside the curly brackets is the index and the second is the alignment. The sign of the second number indicates if the string should be left or right aligned. Use negative numbers for left alignment. Or look at http://msdn.microsoft.com/en-us/library/aa331875(v=vs.71).aspx

Python spacing and aligning strings

You should be able to use the format method: “Location: {0:20} Revision {1}”.format(Location, Revision) You will have to figure out the format length for each line depending on the length of the label. The User line will need a wider format width than the Location or District lines.

Align labels in form next to input

WARNING: OUTDATED ANSWER Nowadays you should definitely avoid using fixed widths. You could use flexbox or CSS grid to come up with a responsive solution. See the other answers. One possible solution: Give the labels display: inline-block; Give them a fixed width Align text to the right That is: label { display: inline-block; width: 140px; … Read more

How to center icon and text in a android button with width set to “fill parent”

All the previous answers seem to be outdated You can use the MaterialButton now which lets setting the icon gravity. <com.google.android.material.button.MaterialButton android:id=”@+id/btnDownloadPdf” android:layout_width=”0dp” android:layout_height=”56dp” android:layout_margin=”16dp” android:gravity=”center” android:textAllCaps=”true” app:backgroundTint=”#fc0″ app:icon=”@drawable/ic_pdf” app:iconGravity=”textStart” app:iconPadding=”10dp” app:iconTint=”#f00″ app:layout_constraintBottom_toBottomOf=”parent” app:layout_constraintEnd_toEndOf=”parent” app:layout_constraintStart_toStartOf=”parent” tools:text=”Download Pdf” /> For using the material components you will obviously need to: Add a dependency implementation ‘com.google.android.material:material:1.3.0-alpha01’ (use latest … Read more

CSS – Make divs align horizontally

You may put an inner div in the container that is enough wide to hold all the floated divs. #container { background-color: red; overflow: hidden; width: 200px; } #inner { overflow: hidden; width: 2000px; } .child { float: left; background-color: blue; width: 50px; height: 50px; } <div id=”container”> <div id=”inner”> <div class=”child”></div> <div class=”child”></div> <div … Read more

Align printf output in Java

You can try the below example. Do use ‘-‘ before the width to ensure left indentation. By default they will be right indented; which may not suit your purpose. System.out.printf(“%2d. %-20s $%.2f%n”, i + 1, BOOK_TYPE[i], COST[i]); Format String Syntax: http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#syntax Formatting Numeric Print Output: https://docs.oracle.com/javase/tutorial/java/data/numberformat.html PS: This could go as a comment to DwB’s … Read more

How to dynamically create controls aligned to the top but after other aligned controls?

Once again, DisableAlign and EnableAlign to the rescue: procedure TForm1.FormCreate(Sender: TObject); var I: Integer; P: TPanel; begin DisableAlign; try for I := 0 to 4 do begin P := TPanel.Create(Self); P.Caption := IntToStr(I); P.Align := alTop; P.Parent := Self; end; finally EnableAlign; end; end; Explanation: When alignment is enabled, every single addition of a control … Read more