.net - How to fix length of characters in DataGrid cells -


I have a datagrid with columns, like IDs with values ​​of 1,2,3,4,5 .... 10, 11,12,13 ... I want all the values ​​to be two lengths, that means I want value 01,02,03 .... 10,11,12 ... how it is Do you?

Edit I am using Winforms.

Edit

  if (dg.Column [column.index] .name == "id") {try {// E.Value = String.Format ("{0: 00.0}", E. Vel); DataGrade View Seleastyl ca = New DataGrid Scene Style (); Ca.Forecolor = System.Drawing.Color.Red; Ca.format = "d2"; Dg.Column [e.ColumnIndex] .DefaultCellStyle = ca; E.formattingApplied = true; } Hold (Format Exception) {E. Formatting = wrong; }}   

Here I am able to replace Icolcolor and forecolor, but the text format is the same, what should I do. I tried to use the string.format (commented line) but it is not working but I also tried your code, it is not working is not known what is wrong.

(DataGridView)

For a DataGridView, Format setting like DefaultCellStyle :

  this.dataGridView1.Column ["COLUMN_NAME"]. DefaultCellStyle.Format = "d2";   

(WinForms DataGrid response)

In WinForms, MSDN says that there is a property on DataGridTextBoxColumn;


(Answer to web form)

You can use the property on the column:

/ P> < Pre> DataFormatString = "{0: D2}"

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -