日期:2014-05-17 浏览次数:21019 次
public Form1() { InitializeComponent(); //Microsoft.CSharp.CSharpCodeProvider my = new CSharpCodeProvider(); DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("c1")); dt.Columns.Add(new DataColumn("c2")); dt.Columns.Add(new DataColumn("c3")); DataRow dr = dt.NewRow(); dr["c1"] = "r1c1"; dr["c2"] = "r1c2"; dr["c3"] = "r1c3"; dt.Rows.Add(dr); dr = dt.NewRow(); dr["c1"] = "r2c1"; dr["c2"] = "r1c2"; dr["c3"] = "r1c3"; dt.Rows.Add(dr); dr = dt.NewRow(); dr["c1"] = "r3c1"; dr["c2"] = "r1c2"; dr["c3"] = "r3c3"; dt.Rows.Add(dr); this.gridControl1.DataSource = dt; } private void gridView1_CellMerge(object sender, DevExpress.XtraGrid.Views.Grid.CellMergeEventArgs e) { //if (e.Column.FieldName== "c2") //{ // if (this.gridView1.GetDataRow(e.RowHandle1)["c3"].ToString() != this.gridView1.GetDataRow(e.RowHandle2)["c3"].ToString()) // e.Handled = true; //} //else if (e.Column.FieldName == "c3") //{ // if (this.gridView1.GetDataRow(e.RowHandle1)["c2"].ToString() != this.gridView1.GetDataRow(e.RowHandle2)["c2"].ToString()) // e.Handled = true; //} if ((this.gridView1.GetDataRow(e.RowHandle1)["c2"].ToString() != this.gridView1.GetDataRow(e.RowHandle2)["c2"].ToString()) ||(this.gridView1.GetDataRow(e.RowHandle1)["c3"].ToString() != this.gridView1.GetDataRow(e.RowHandle2)["c3"].ToString())) e.Handled = true; }