HOW TO SET DATAGRIDVIEW FORMATTING IN C#

Jayden Bell

Total Post:110

Points:774
Posted by  Jayden Bell
C# 
C#
 1144  View(s)
Ratings:
Rate this:
Hi developers,

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

  1. Sumit Kesarwani

    Post:378

    Points:2694
    Re: How to set datagridview formatting in C#

    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.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!