我在gridview中添加了一个新的ButtonEdit列,我将按钮转到了ImageButton。我添加了button_click事件,但事件未触发。 我应该绑定 - 将未绑定的内容绑定到我的列按钮上吗?
以下是属性:
//
// 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);**
粗体线条,我得到了可能阻止事件发生的可疑属性?
感谢您的帮助。 问候, Cihat
答案 0 :(得分:13)
当视图不可编辑时,您无法单击ButtonEdit按钮,因为编辑器仅在此情况下被绘制但未被调用。
将gvPrompt.OptionsBehavior.Editable
属性设置为true
。然后,将每个列(具有ButtonEdit的列除外)GridColumn.OptionsColumn.AllowEdit
属性设置为false
。它允许具有ButtonEdit的列可编辑,编辑器的按钮可以“点击”。
请同时删除this.gvPrompt.OptionsBehavior.EditorShowMode = DevExpress.Utils.EditorShowMode.Click;
行。它允许按钮编辑立即点击鼠标而不是首先聚焦细胞。