Pages

Tuesday, November 23, 2010

C# Datagridview Disable Sorting.

To Disable sorting in DataGridView.Do the following.


To manually disable sorting do the following.
Column1.SortMode = DataGridViewColumnSortMode.NotSortable;

Thursday, November 4, 2010

String.format in c sharp, padding with zeros e.g 1 to 001

If you want to pad zero's in front of a number in c# .Net
i.e for example if the given number is 24 and you need to add zero's in front of if
then you should do the following.


e.g Assuming that it is a number, not a string.
Int a=24;// To 0024 


string newStr = String.Format("{0:0000}", 24]);
Output of newStr will be 0024