http://forums.codeguru.com/showthread.php?415930-DataGridView-Merging-Cells
Inheritance: System.Windows.Forms.DataGridViewTextBoxCell
Ejemplo n.º 1
0
        private DataGridViewRow AddRowSep(DuplicateArchiveInfo data)
        {
            int             index = dgvResult.Rows.Add();
            DataGridViewRow row   = dgvResult.Rows[index];

            row.DefaultCellStyle.BackColor = Color.Black;

            row.ReadOnly = true;
            var cellCheck = new HMergedCell();

            cellCheck.LeftColumn  = 0;
            cellCheck.RightColumn = 1;
            cellCheck.Value       = data.DupGroup.ToString("D4");
            row.Cells["colCheck"] = cellCheck;

            var cellGroup = new HMergedCell();

            cellGroup.LeftColumn     = 0;
            cellGroup.RightColumn    = 1;
            cellGroup.Value          = data.DupGroup.ToString("D4");
            row.Cells["colDupGroup"] = cellGroup;

            string filenameOnly = data.Filename.Substring(data.Filename.LastIndexOf("\\") + 1);

            row.Cells["colFilename"] = new HMergedCell();
            var mergedCells = (HMergedCell)row.Cells["colFilename"];

            mergedCells.LeftColumn  = 2;
            mergedCells.RightColumn = 13;
            mergedCells.Value       = filenameOnly;

            int nOffset = 2;

            for (int j = nOffset; j < 14; j++)
            {
                row.Cells[j] = new HMergedCell();
                HMergedCell pCell = (HMergedCell)row.Cells[j];
                pCell.LeftColumn  = 2;
                pCell.RightColumn = 13;
                pCell.Value       = filenameOnly;
            }
            row.Cells["colMatchType"].Value = "SEPARATOR";

            // Fill numeric data for sorting
            row.Cells["colItemsCount"].Value   = -1;
            row.Cells["colFileSize"].Value     = -1L;
            row.Cells["colCreationTime"].Value = DateTime.MinValue;
            return(row);
        }