I did it.....
At first using CellFormatting Event
private void mgrdContentDatabase_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if(this.mgrdContentDatabase.Columns[e.ColumnIndex].HeaderText== "Size(GB)")
{
if (e.Value != null)
{
CovertFileSize(e);
}
}
}
and then make a Convert to file size method
private void CovertFileSize(DataGridViewCellFormattingEventArgs formatting)
{
if (formatting.Value != null)
{
try
{
long bytes;
bytes = Convert.ToInt64(formatting.Value);
string size = "0 Bytes";
if (bytes >= 1073741824.0)
size = String.Format("{0:##.##}", bytes / 1073741824.0) + " GB";
else if (bytes >= 1048576.0)
size = String.Format("{0:##.##}", bytes / 1048576.0) + " MB";
else if (bytes >= 1024.0)
size = String.Format("{0:##.##}", bytes / 1024.0) + " KB";
else if (bytes > 0 && bytes < 1024.0)
size = bytes.ToString() + " Bytes";
formatting.Value = size;
formatting.FormattingApplied = true;
}
catch(FormatException)
{
formatting.FormattingApplied = false;
}
}
}