Why PADL and PADR Not Working in Textbox and Other Control And same Working in Console Window Formatting text with padding does not line up in C#

 

Why PADL  and PADR Not Working in Textbox and Other Control And same Working in Console Window

Formatting text with padding does not line up in C#

 

Grid                                                                                                      

Label Control

 

Your problem is kerning [Each Character are of different Size and Width take are Different]. Change your text to a monospaced font (where all the characters are the same width) or use a control that has actual columns instead of trying to match up padding. Consolas is the default font in visual studio and is monospaced, for example

 Text box Control



Monospaced typefaces :  Courier, a monospaced slab serif typeface. All the letters occupy spaces the same width.

Monospaced fonts are typefaces in which every glyph is the same width (as opposed to variable-width fonts, where the w and m are wider than most letters, and the i is narrower). The first monospaced typefaces were designed for typewriters, which could only move the same distance forward with each letter typed. Their use continued with early computers, which could only display a single font. Although modern computers can display any desired typeface, monospaced fonts are still important for computer programming, terminal emulation, and for laying out tabulated data in plain text documents; they may also be particularly legible at small sizes due to all characters being quite wide.[34] Examples of monospaced typefaces are Courier, Prestige Elite, Fixedsys, and Monaco. Most monospaced fonts are sans-serif or slab-serif as these designs are easiest to read printed small or display on low-resolution screens, though many exceptions exist.

 

Code

Private Sub Form35_Load(sender As Object, e As EventArgs) Handles MyBase.Load

 

           Dim strValue As New StringBuilder

        strValue.AppendLine("Progamming".PadRight(11) & "Visual Studio")

        strValue.AppendLine("Exp".PadRight(11) & "12 Years")

        GridControl1.Item(2, 1).CellValue = strValue

        TextBox1.Text = strValue.ToString

        Label2.Text = strValue.ToString

 

        Console.WriteLine(strValue)

    End Sub

Comments

Popular posts from this blog

Shared / Static Class in vb.net/C#

Xamarin Forms : PopUp Page with RG.Plugins.Popup

Text was truncated or one or more characters had no match in the target code page.". (SQL Server Import and Export Wizard)