0

I have look into Here for solution but it would say index out of bound on when the datagridviewcell instance is being assigned with value,and also the function for datagridview on paint makes my gridview unable to display so i have to rollback my code.

This is the original grid enter image description here

and i want it to become something like


enter image description here

Jesse
  • 65
  • 1
  • 17

1 Answers1

1

How to Merge DataGridView Cell in Winformsenter link description here

This is the answer, because of my own mistake for not noticing the parameter for column and row are actually passed from cellpainting and cellformatting. This is the perfect answer

bool IsTheSameCellValue(int column, int row)
{
    DataGridViewCell cell1 = dataGridView1[column, row];
    DataGridViewCell cell2 = dataGridView1[column, row - 1];
    if (cell1.Value == null || cell2.Value == null)
    {
       return false;
    }
    return cell1.Value.ToString() == cell2.Value.ToString();
}
Jesse
  • 65
  • 1
  • 17