0

I have a datagridview with three columns where, everytime I only have one value, I want to merge my columns, similarly to the picture below:

enter image description here

I have made sure to have my three column values for each row split by '-'.
In that case, the datagridview takes those values from my database and splits them before adding them to their respective columns.
Here's a chunk of my code:

String[] splitter = new string[3];
try
{
string a = datagridview2. Rows[row. Index]. Cells[$"{combobox1. Text + combobox2. Text}datagridviewtextboxcolumn"]. Value == null ? String. Empty : datagridview2. Rows[row. Index]. Cells[$"{combobox1. Text + combobox2. Text}datagridviewtextboxcolumn"]. Value. Tostring();

if (a. Contains('-'))
{
splitter = a. Split('-');
row. Cells["column1"]. Value = splitter[0];
row. Cells["column2"]. Value = splitter[1];
row. Cells["column3"]. Value = splitter[2];

}
else
{
row. Cells["tolerancemindatagridviewtextboxcolumn"]. Value = a;

//code pour merge
}

}
catch { exception exception; }

I've tried playing around with the style methods but none of them seem to work. Does anyone have any idea on how to do it?

delirium78
  • 612
  • 4
  • 13

0 Answers0