how to merge cell datagridview in WindowsForm c# -


i have datagridview mysql database below:

mydatagridview

i want combine data row has same value. result looks following:

mydatagridviewresult

this function merge cells want:

private void mergecells() {      hierarchyitem rowitem1 = grid.rowshierarchy.items[0];     hierarchyitem columnitem1 = grid.columnshierarchy.items[0];      // create custom cell style.     gridcellstyle style = new gridcellstyle();     style.fillstyle = new fillstylesolid(color.fromargb(255, 0, 175, 240));     style.font = new font(this.font.fontfamily, 11.0f, fontstyle.bold);     style.textcolor = color.white;     gridcellstyle orangestyle = new gridcellstyle();     orangestyle.fillstyle = new fillstylesolid(color.fromargb(255, 254, 122, 1));     orangestyle.font = new font(this.font.fontfamily, 10.0f, fontstyle.bold);     orangestyle.textcolor = color.white;     grid.cellsarea.setcelltextalignment     (rowitem1, columnitem1, contentalignment.middlecenter);     // set cell span 1 row , 5 columns.     grid.cellsarea.setcellspan(rowitem1, columnitem1, 1, 5);     // set merged cell value , style.     grid.cellsarea.setcelldrawstyle(rowitem1, columnitem1, style);     // set cell span 1 row , 2 columns.     grid.cellsarea.setcellspan(grid.rowshierarchy.items[1], columnitem1, 1, 3);     grid.cellsarea.setcelldrawstyle     (grid.rowshierarchy.items[1], columnitem1, orangestyle);      // set merged cell value.      // set cell span 1 row , 2 columns.     grid.cellsarea.setcellspan     (grid.rowshierarchy.items[1], this.grid.columnshierarchy.items[3], 1, 2);      // set merged cell value.     grid.cellsarea.setcelldrawstyle     (grid.rowshierarchy.items[1], this.grid.columnshierarchy.items[3], orangestyle); } 

Comments

Popular posts from this blog

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -