Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
- {
- var dataGridView = sender as DataGridView;
- if (dataGridView.Rows[e.RowIndex].Selected)
- {
- e.CellStyle.Font = new Font(e.CellStyle.Font, FontStyle.Bold);
- // edit: to change the background color:
- e.CellStyle.SelectionBackColor = Color.Coral;
- }
- }
- private void dg_RowEnter(object sender, DataGridViewCellEventArgs e)
- {
- System.Windows.Forms.DataGridViewCellStyle boldStyle = new System.Windows.Forms.DataGridViewCellStyle();
- boldStyle.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold);
- dg.Rows[e.RowIndex].DefaultCellStyle = boldStyle;
- }
- private void dg_RowLeave(object sender, DataGridViewCellEventArgs e)
- {
- System.Windows.Forms.DataGridViewCellStyle norStyle = new System.Windows.Forms.DataGridViewCellStyle();
- norStyle.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular);
- dg.Rows[e.RowIndex].DefaultCellStyle = norStyle;
- }
- if (e.Row.RowType == DataControlRowType.DataRow)
- {
- if (e.Row.Cells[rowIndex].Text == "Total")
- {
- e.Row.Font.Bold = true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement