Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
  2. {
  3. var dataGridView = sender as DataGridView;
  4. if (dataGridView.Rows[e.RowIndex].Selected)
  5. {
  6. e.CellStyle.Font = new Font(e.CellStyle.Font, FontStyle.Bold);
  7. // edit: to change the background color:
  8. e.CellStyle.SelectionBackColor = Color.Coral;
  9. }
  10. }
  11.  
  12. private void dg_RowEnter(object sender, DataGridViewCellEventArgs e)
  13. {
  14. System.Windows.Forms.DataGridViewCellStyle boldStyle = new System.Windows.Forms.DataGridViewCellStyle();
  15. boldStyle.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
  16. dg.Rows[e.RowIndex].DefaultCellStyle = boldStyle;
  17. }
  18.  
  19. private void dg_RowLeave(object sender, DataGridViewCellEventArgs e)
  20. {
  21. System.Windows.Forms.DataGridViewCellStyle norStyle = new System.Windows.Forms.DataGridViewCellStyle();
  22. norStyle.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular);
  23. dg.Rows[e.RowIndex].DefaultCellStyle = norStyle;
  24. }
  25.  
  26. if (e.Row.RowType == DataControlRowType.DataRow)
  27. {
  28. if (e.Row.Cells[rowIndex].Text == "Total")
  29. {
  30. e.Row.Font.Bold = true;
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement