LiterallyGuts 0 Newbie Poster

Hello everyone,

I'm currently working on a project, and I have to edit a table,by merging certain cells.
Below is a picture summarizing my situation as well as a snippet of my code where my code works for the right cell but not the left one :

Capture.PNG

private void dataGridView2_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
        {
            if (e.ColumnIndex == 1)
            {

                e.AdvancedBorderStyle.Bottom = DataGridViewAdvancedCellBorderStyle.None;
                if(e.RowIndex == 0) {
                    e.AdvancedBorderStyle.Top = DataGridViewAdvancedCellBorderStyle.Single;

                }
                if (e.RowIndex < 1 || e.ColumnIndex < 0)
                    return;
                if (IsTheSameCellValue(e.ColumnIndex, e.RowIndex))
                  {
                        e.AdvancedBorderStyle.Top = DataGridViewAdvancedCellBorderStyle.None;

                  }
                else
                  {
                        e.AdvancedBorderStyle.Top = DataGridViewAdvancedCellBorderStyle.Single;
                  }
            }
            else 
            {
                if ((e.Value?.ToString() == "")&&(e.ColumnIndex==3))
                {
                    e.AdvancedBorderStyle.Right = DataGridViewAdvancedCellBorderStyle.None;

                }

                if ((e.Value?.ToString() == "") && (e.ColumnIndex == 5))
                {
                    e.AdvancedBorderStyle.Left = DataGridViewAdvancedCellBorderStyle.OutsetDouble;

                }
            }


        }

Can anyone please help me? Thank you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.