Home > DeveloperSection > Forums > How to set datagridview formatting in C#
Jayden Bell
Jayden Bell

Total Post:105

Points:739
Posted on    June-15-2013 4:35 AM

 C# C# 
Ratings:


 1 Reply(s)
 826  View(s)
Rate this:
Hi developers,

I want to change my datagridview appearance so please any body provide me any demo for datagridview formatting.



Sumit Kesarwani

Total Post:378

Points:2694
Posted on    June-15-2013 7:48 AM

Hi Jayden,

You can use this code:

1.  private void Form1_Load(object sender, EventArgs e)

2.  {

3.  dataGridView1.RowsDefaultCellStyle.BackColor = Color.AliceBlue;

4.  dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.Aqua;

5.  dataGridView1.CellBorderStyle = DataGridViewCellBorderStyle.None;

6.  dataGridView1.DefaultCellStyle.SelectionBackColor = Color.CadetBlue;

7.  dataGridView1.DefaultCellStyle.SelectionForeColor = Color.White;

8.  dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;

9.  }

Code description:

1.       This is the Form1_Load event.

3.       Here set the default rows back color.

4.       Here set the alternative row back color.

5.       Here set the datagridview cell border none.

6.       Here set the datagridview selected row back color.

7.       Here set the datagridview selected row forecolor.

8.       Here when I click any cell entire row will selected.


Don't want to miss updates? Please click the below button!

Follow MindStick