C# WinForm DataGrid CellFormatting Does Not Work In Datasource Issues
<p>Good day, I'm showing my queries from table in to the datagrid. But I'm having a problem with my codes. I tried to debug and add break point in my dgview_CellFormatting but the my code doesn't go to the event handler of cell formatting. I don't know why.</p>

<p>Here's my code. I put my datasource in my Form load</p>

<pre><code>// dgv_details is supposed to be my datagrid view name.

DataTable table;

table = balreport.SelectDetails(belreport); // responsible for fetching data from the database.

this.dgv_details.DataSource = table;

this.dgv_details.Sort(this.dgv_details.Columns[0], ListSortDirection.Ascending);
// For sorting the data
foreach (DataGridViewColumn column in this.dgv_details.Columns)
{
    column.SortMode = DataGridViewColumnSortMode.NotSortable;
}

this.dgv_details.CellFormatting += dgv_details_CellFormatting;
</code></pre>

<p>And here's my dgv_details_CellFormatting event handler</p>

<pre><code> if (e.ColumnIndex == 0 &amp;&amp; e.RowIndex &gt; 0)
 {
     if (dgv_salesdetails[0, e.RowIndex].Value == dgv_salesdetails[0, e.RowIndex - 1].Value)
     e.Value = "";
 }
</code></pre>

<p>The sorting is working properly, but the problem is, the e.Value should be hide.
The result should be something like this image</p>

<p><a href="https://i.stack.imgur.com/OOadU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OOadU.png" alt="enter image description here"></a></p>

<p>I really need a help.</p>