Donate

Change DataGridViewRow FontStyle To Bold In CellFormatting Event

Hello,
There was a question raised in the forums on how to change the FontStyle of a DataGridViewRow to Bold in the CellFormatting event. A solution is to set the Font property of a row with a Font object setting it's second parameter to FontStyle.Bold.
private void EmployeeDTRDataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
 if (EmployeeDTRDataGridView.Columns[e.ColumnIndex].Name == "OnLeave")
 {
  if (e.Value != System.DBNull.Value)
  {
   if (Convert.ToBoolean(e.Value) == true)
   {
    EmployeeDTRDataGridView.Rows[e.RowIndex].DefaultCellStyle.Font = new Font(e.CellStyle.Font, FontStyle.Bold);
   }
  }
 }
}

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

How To Insert Or Add Emojis In Microsoft Teams Status Message

Bootstrap Modal In ASP.NET MVC With CRUD Operations