• devexpress gridview 添加按钮


    #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

  • 相关阅读:
    每天一个设计模式(2):观察者模式
    每天一个设计模式(1):策略模式
    每天一个设计模式(0):设计模式概述
    常量池、栈、堆的比较
    常量池小结
    Java虚拟机体系结构分析
    Java并发(3):volatile及Java内存模型
    第一题:Big Countries
    22 高级SQL特性
    21 使用游标
  • 原文地址:https://www.cnblogs.com/aj407blogs/p/9887637.html
Copyright © 2020-2023  润新知