日期:2014-05-17  浏览次数:20955 次

datagridview 合并单元格问题
在这里看了些资料,
http://www.cnblogs.com/peterzb/archive/2009/05/29/1491891.html
使用rowmergeview做单元格合并和二维表头,

前两列都可以,第三列数字列却合并不了,试了好久,有没有谁用过这个控件?指条明路啊!
下面是代码

        private void dgvColumnsBindC()
        {
            this.rmvItem.EnableHeadersVisualStyles = false;
            this.rmvItem.AutoGenerateColumns = false;
            this.rmvItem.Columns.Clear();//列头清空下

            Dictionary<string, string> dataText = new Dictionary<string, string>();
            dataText.Add("ItemName", "考核类型");
            dataText.Add("IName", "考核项目");
            dataText.Add("Weights", "权重");
            dataText.Add("Description", "考核明细");
            dataText.Add("Scores", "分值");

            foreach (KeyValuePair<string, string> kvp in dataText)
            {
                DataGridViewTextBoxColumn dgvc = new DataGridViewTextBoxColumn();
                dgvc.DataPropertyName = kvp.Key;
                dgvc.HeaderText = kvp.Value;
                dgvc.Name = kvp.Key;
                dgvc.ReadOnly = true;
                if (kvp.Value == "权重" || kvp.Value == "分值") dgvc.DefaultCellStyle.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
                if (kvp.Value == "考核类型" || kvp.Value == "考核项目") dgvc.DefaultCellStyle.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
                if (kvp.Value == "考核明细") dgvc.DefaultCellStyle.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
                dgvc.HeaderCell.Style.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;//居中
                dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
                if (kvp.Value == "权重" || kvp.Value