GridControl的单元格中以buttonEdit实现文字和图片按钮并存的效果

时间:2023-12-22 13:33:26

话不多说,先上效果图

GridControl的单元格中以buttonEdit实现文字和图片按钮并存的效果

对于第一列的效果是如何实现的就不多说了,网上有很多例子

重点是第三列的效果实现方法,代码如下

 private void GridSet()
{
//DevExpress.XtraEditors.Controls.EditorButton editorBtn = new EditorButton();
//editorBtn.Kind = ButtonPredefines.Glyph;
//editorBtn.Image = Image.FromFile("u56558.png"); DevExpress.XtraEditors.Repository.RepositoryItemButtonEdit btnEdit = new RepositoryItemButtonEdit();

btnEdit.Buttons[0].Kind = ButtonPredefines.Glyph;
               btnEdit.Buttons[0].Image = Image.FromFile("u56558.png");
btnEdit.ButtonsStyle = BorderStyles.UltraFlat;
btnEdit.TextEditStyle = TextEditStyles.DisableTextEditor; bandedGridColumn3.ColumnEdit = btnEdit; bandedGridColumn3.ShowButtonMode = DevExpress.XtraGrid.Views.Base.ShowButtonModeEnum.ShowAlways; btnEdit.ButtonClick += (s, e) =>
{
MessageBox.Show("oh!yes");
};
}