本文介绍了DevExpress XtraGrid RepositoryItemButtonEdit事件未触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的gridview中添加了一个新的ButtonEdit列,将按钮转到了ImageButton.我添加了button_click事件,但事件未触发.我应该绑定-取消绑定到我的columnbutton上的东西吗?

I have added a new ButtonEdit column to my gridview, I turned buttons to ImageButton. I added button_click event but event is not firing.Should I bound - unbound something to my columnbutton?

以下是属性:

        //
        // gvPrompt
        //
        this.gvPrompt.Columns.AddRange(new DevExpress.XtraGrid.Columns.GridColumn[] {
        this.gcID,
        this.gcName,
        this.gcPromptFileName,
        this.gcTypeName,
        this.gcDomainName,
        this.gcPromptText,
        this.gcLanguage,
        this.gcPromptPlayType,
        this.gcDuration,
        this.colPlayPrompt});
        **this.gvPrompt.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus;**
        this.gvPrompt.GridControl = this.gcPrompt;
        this.gvPrompt.Name = "gvPrompt";
        this.gvPrompt.OptionsBehavior.AllowAddRows = DevExpress.Utils.DefaultBoolean.False;
        this.gvPrompt.OptionsBehavior.AllowDeleteRows = DevExpress.Utils.DefaultBoolean.False;
        this.gvPrompt.OptionsBehavior.Editable = false;
        **this.gvPrompt.OptionsBehavior.EditorShowMode = DevExpress.Utils.EditorShowMode.Click;**
        this.gvPrompt.OptionsCustomization.AllowGroup = false;
        this.gvPrompt.OptionsSelection.EnableAppearanceFocusedCell = false;
        this.gvPrompt.OptionsView.ShowGroupPanel = false;
        this.gvPrompt.RowHeight = 3;
        **this.gvPrompt.ShowButtonMode = DevExpress.XtraGrid.Views.Base.ShowButtonModeEnum.ShowForFocusedRow;
        this.gvPrompt.FocusedRowChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventHandler(this.gvStep_FocusedRowChanged);**


         //
        // colPlayPrompt
        //
        this.colPlayPrompt.Caption = "Çal";
        this.colPlayPrompt.ColumnEdit = this.repositoryItemButtonEdit1;
        this.colPlayPrompt.FieldName = "Column";
        this.colPlayPrompt.ImageAlignment = System.Drawing.StringAlignment.Center;
        this.colPlayPrompt.Name = "colPlayPrompt";
        **this.colPlayPrompt.ShowButtonMode = DevExpress.XtraGrid.Views.Base.ShowButtonModeEnum.ShowAlways;**
        this.colPlayPrompt.Visible = true;
        this.colPlayPrompt.VisibleIndex = 9;
        this.colPlayPrompt.Width = 86;



        //
        // repositoryItemButtonEdit1
        //
        this.repositoryItemButtonEdit1.Appearance.Image = global::Digiturk.Diva.Management.Properties.Resources._1358361116_youtube;
        this.repositoryItemButtonEdit1.Appearance.Options.UseImage = true;
        this.repositoryItemButtonEdit1.AutoHeight = false;
        serializableAppearanceObject2.Options.UseImage = true;
        this.repositoryItemButtonEdit1.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
        new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Glyph, "", 1, true, true, false, DevExpress.XtraEditors.ImageLocation.MiddleCenter, global::Digiturk.Diva.Management.Properties.Resources._1358361116_youtube, new DevExpress.Utils.KeyShortcut(System.Windows.Forms.Keys.None), serializableAppearanceObject2, "", null, null, true)});
        this.repositoryItemButtonEdit1.ButtonsStyle = DevExpress.XtraEditors.Controls.BorderStyles.Style3D;
        this.repositoryItemButtonEdit1.Name = "repositoryItemButtonEdit1";
        this.repositoryItemButtonEdit1.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.HideTextEditor;
        **this.repositoryItemButtonEdit1.ButtonClick += new DevExpress.XtraEditors.Controls.ButtonPressedEventHandler(this.repositoryItemButtonEdit1_ButtonClick);
        this.repositoryItemButtonEdit1.ButtonPressed += new DevExpress.XtraEditors.Controls.ButtonPressedEventHandler(this.repositoryItemButtonEdit1_ButtonPressed);
        this.repositoryItemButtonEdit1.Click += new System.EventHandler(this.repositoryItemButtonEdit1_Click);**

我发现具有可疑属性的行可能会阻止事件触发?

bolded lines that I got suspicious properties which may prevent event firing?

感谢您的帮助.问候,Cihat

Thanks for your help.Regards,Cihat

推荐答案

当视图不可编辑时,您将无法单击ButtonEdit按钮,因为在这种情况下,编辑器只能绘制但不能调用.

You can't click the ButtonEdit buttons when the view is not editable because the editors only drawn but not invoked in this case.

gvPrompt.OptionsBehavior.Editable属性设置为true.然后,将每列(具有ButtonEdit的列除外)的GridColumn.OptionsColumn.AllowEdit属性设置为false.它允许带有ButtonEdit的列是可编辑的,而编辑器的按钮是可单击的".

Set the gvPrompt.OptionsBehavior.Editable property to true. Then, set each column's (except the column with the ButtonEdit) GridColumn.OptionsColumn.AllowEdit property to false. It allows the column with the ButtonEdit to be editable and the editor's buttons to be "clickable".

也请删除this.gvPrompt.OptionsBehavior.EditorShowMode = DevExpress.Utils.EditorShowMode.Click;行.它允许按钮编辑立即对鼠标单击做出反应,而无需首先关注单元格.

Please also remove the this.gvPrompt.OptionsBehavior.EditorShowMode = DevExpress.Utils.EditorShowMode.Click; line. It allows the button edit to react on mouse click immediatelly instead of focusing cell first.

这篇关于DevExpress XtraGrid RepositoryItemButtonEdit事件未触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 21:46