#region 添加按钮事件
private RepositoryItemButtonEdit CreateRepositoryItemButtonEdit(Dictionary<object, string> dicButtons)
{ RepositoryItemButtonEdit repositoryBtn = new RepositoryItemButtonEdit(); repositoryBtn.AppearanceDisabled.Options.UseTextOptions = true;
repositoryBtn.AppearanceDisabled.TextOptions.HAlignment = HorzAlignment.Near;
repositoryBtn.AutoHeight = false;
repositoryBtn.TextEditStyle = TextEditStyles.HideTextEditor;
repositoryBtn.ButtonsStyle = BorderStyles.Office2003;
repositoryBtn.Buttons.Clear();
EditorButton btn = null;
foreach (KeyValuePair<object, string> item in dicButtons)
{
btn = new EditorButton();
btn.Kind = ButtonPredefines.Glyph;
btn.Caption = item.Value;
//btn.Appearance.ForeColor = Color.Red;
btn.Tag = item.Key;
repositoryBtn.Buttons.Add(btn);
}
return repositoryBtn;
} private void ribeFile_ButtonClick(object sender,ButtonPressedEventArgs e)
{
int i = gridView1.FocusedRowHandle;
MessageBox.Show(i.ToString()+ e.Button.Caption) ;
switch (e.Button.Caption)
{
case "核销":break;
case "现缴":break;
case "开票": break;
default:
break;
}
} #endregion
//RepositoryItemButtonEdit rib = new RepositoryItemButtonEdit();//Button按钮
//rib.TextEditStyle = TextEditStyles.HideTextEditor;//隐藏文字
//rib.Buttons[0].Kind = ButtonPredefines.Glyph;//按钮样式
////rib.Buttons[0].ImageOptions.Image = ;
//rib.ButtonClick += this.Copy_Clik;
//rib.Buttons[0].Caption = "复制";//按钮上的文字 //RepositoryItemButtonEdit ribeFile = new RepositoryItemButtonEdit();
//ribeFile.Buttons.Add(rib); Dictionary<object, string> dicButtons = new Dictionary<object, string>();
dicButtons.Add("verification", "核销");
dicButtons.Add("pay", "缴费");
dicButtons.Add("open_ticket", "开票");
RepositoryItemButtonEdit ribeFile = CreateRepositoryItemButtonEdit(dicButtons);
ribeFile.ButtonClick += ribeFile_ButtonClick; //绑定事件
//gcData.RepositoryItems.Add(ribeFile);
//this.Operate.ColumnEdit = ribeFile; gridColumn12.ColumnEdit = ribeFile; gridView1.BestFitColumns();//自动列宽
转自 https://www.cnblogs.com/qq-xiao/p/6122573.html