How to set datagridview formatting in C#

Total Post:110

 1553  View(s)
Rate this:
Hi developers,

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

  1. Post:378

    Re: How to set datagridview formatting in C#

    Hi Jayden,

    You can use this code:

      private void Form1_Load(object sender, EventArgs e)
    dataGridView1.RowsDefaultCellStyle.BackColor = Color.AliceBlue;
    dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.Aqua;
    dataGridView1.CellBorderStyle = DataGridViewCellBorderStyle.None;
    dataGridView1.DefaultCellStyle.SelectionBackColor = Color.CadetBlue;
    dataGridView1.DefaultCellStyle.SelectionForeColor = Color.White;
    dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;

    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.

      Modified On Mar-30-2018 04:17:55 AM