---
title: "Datagridview Formatting in C#"  
description: "In this article I am trying to explain how to change the formatting of datagridview in C#."  
author: "Vijay Shukla"  
published: 2013-06-23  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/1355/datagridview-formatting-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Datagridview Formatting in C#

In this [article](https://yourviews.mindstick.com/view/81489/kashmir-now-after-an-year-of-abrogation-of-article-370) I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to explain how to change the formatting of [datagridview in C#](https://www.mindstick.com/forum/523/set-button-name-in-datagridview-in-c-sharp).\

The DataGridView [control](https://yourviews.mindstick.com/view/83439/bipartisan-gun-control-bill-passed-in-us-after-decades) is extremely configurable and [extensible](https://www.mindstick.com/blog/59/xaml-extensible-application-markup-language); DataGridView provides many [properties](https://yourviews.mindstick.com/view/81845/now-it-s-possible-to-predict-properties-of-any-molecule), [methods](https://www.mindstick.com/articles/13060/runny-nose-remedy-methods-that-work-best), and events to modify its look and behavior. The DataGridView control makes it simple to define the basic appearance of cells and the display formatting of cell values. Below I write few line of code for formatting DataGridView appearance in C#.

##### Write the below code for change your DataGridView appearance

```
 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](https://www.mindstick.com/forum/2324/what-is-the-alternative-to-the-mvc) 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](https://answers.mindstick.com/qa/46828/if-i-buy-an-entire-row-of-seats-on-a-long-flight-so-no-one-is-next-to-me-can-the-airline-sell-one-of-my-empty-seats-to-someone-or-will-they-respect-the-fact-that-the-empty-seats-are-mine-to-do-as-i-p) will selected.

##### Output: -

![Datagridview Formatting in C#](https://www.mindstick.com/mindstickarticle/200412d5-8d01-4fd4-94bc-bfa590bd12c9/images/a6b311e0-8b58-460d-9ee1-d1c24c2b000e.png)

---

Original Source: https://www.mindstick.com/articles/1355/datagridview-formatting-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
