1.在设计器里面添加一列,设置单元格不可编辑、只读属性
2. 在所在GridView属性里面添加CustomDrawCell事件与RowCellClick事件
private void gvMain_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e) { if (e.Column.FieldName == "btnReport") // 指定要添加按钮的列 { e.Appearance.BackColor = Color.FromArgb(220, 233, 247); // 设置按钮的背景颜色 e.Appearance.ForeColor = Color.Black; // 设置按钮的前景颜色 e.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; // 设置按钮的水平对齐方式 e.Appearance.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Center; // 设置按钮的垂直对齐方式 e.DisplayText = "报 工"; // 设置按钮的文本 } } private void gvMain_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e) { if (e.Column.FieldName == "btnReport") // 指定要添加按钮的列 { ///按钮事件 } }
3.效果图
标签:行内,DevExpress,Appearance,private,添加,设置,按钮,WinForm From: https://www.cnblogs.com/wofeiliangren/p/17628283.html