GridView列相同合併

Wangbin0007發表於2024-07-19

private void gridView1_CellMerge(object sender, DevExpress.XtraGrid.Views.Grid.CellMergeEventArgs e)
{
if (e.Column.FieldName == "SPARE_ITEM_6")
{
string a1 = this.gridView1.GetRowCellValue(e.RowHandle1, "SPARE_ITEM_6").ToString();
string a2 = this.gridView1.GetRowCellValue(e.RowHandle2, "SPARE_ITEM_6").ToString();

            string a3 = this.gridView1.GetRowCellValue(e.RowHandle1, "SPARE_ITEM_2").ToString();
            string a4 = this.gridView1.GetRowCellValue(e.RowHandle2, "SPARE_ITEM_2").ToString();
            
            e.Merge = a1 == a2 ;
            
           

        }
        else if (e.Column.FieldName == "ROLL_PLAN_NO")
        {
            string a3 = this.gridView1.GetRowCellValue(e.RowHandle1, "ROLL_PLAN_NO").ToString();
            string a4 = this.gridView1.GetRowCellValue(e.RowHandle2, "ROLL_PLAN_NO").ToString();

            e.Merge = a3 == a4;

            e.Handled = true;

        }
        else
        {
            e.Merge =false;
          
        } e.Handled = true;
    }

相關文章