0

I have the following column defined inside of an XtraGrid. The column consists of dropdowns that force a user to choose one of 3 options. How can I wire an event that fires each time a user changes the value of a dropdown?

this.myCol.AppearanceCell.Options.UseTextOptions = true;
this.myCol.AppearanceCell.TextOptions.HAlignment = 
    DevExpress.Utils.HorzAlignment.Near;
this.myCol.Caption = "My Caption";
this.myCol.ColumnEdit = this._myRepositoryLookup;
this.myCol.FieldName = "MyFieldName";
this.myCol.Name = "myId";
this.myCol.Visible = true;
this.myCol.VisibleIndex = 5;
this.myCol.Width = 252;
4

3 に答える 3

1

You need to look at

GridView.CustomRowCellEdit Event or Repository Items Event

Here is a sample

using DevExpress.XtraGrid.Views.Grid;

private void gridView1_CustomRowCellEdit(object sender, CustomRowCellEditEventArgs e) {
   if (e.Column.FieldName == "FieldName") return;
   GridView gv = sender as GridView;
   string fieldName = gv.GetRowCellValue(e.RowHandle, gv.Columns["FieldName"]).ToString();
   switch (fieldName) {
      case "Population":
         e.RepositoryItem = repositoryItemSpinEdit1;
         break;
      case "Country":
         e.RepositoryItem = repositoryItemComboBox1;
         break;
      case "Capital":
         e.RepositoryItem = repositoryItemCheckEdit1;
         break;
   }           
}

Additional reading here

于 2013-01-14T23:41:42.917 に答える
1

You can subscribe to any RepositoryItemLookUpEdit Events, that you want to raise while working with these repository item controls.

For your requirement, you should use RepositoryItem.EditValueChanged Event, it Fires immediately after changing the edit value.

Note

The EditValueChangedFiringMode property is ignored for lookup editors during an incremental search while their popup windows are open. If the editor's edit value is changed during an incremental search, the EditValueChanged event fires immediately.

Code snippet:

_myRepositoryLookup.EditValueChanged += new EventHandler(_myRepositoryLookup_EditValueChanged);
this.myCol.AppearanceCell.Options.UseTextOptions = true;
this.myCol.AppearanceCell.TextOptions.HAlignment = 
                        DevExpress.Utils.HorzAlignment.Near;
this.myCol.Caption = "My Caption";
this.myCol.ColumnEdit = this._myRepositoryLookup;

LookupEdit event handler method

void _myRepositoryLookup_EditValueChanged(object sender, EventArgs e)
{
    //your code here
}

If you want to assign editors to individual cells then you can use GridView.CustomRowCellEdit Event

References that may help you:
DevExpress RepositoryItemLookUpEdit
Get Cell Control of GridView in DevExpress

于 2013-01-15T06:03:23.513 に答える
1

Add an event directly to the Repository Item.

That way you can choose from the events of a Drop Down and not a column or cell.

repositoryItem.EditValueChanged += new System.EventHandler(repositoryItem_EditValueChanged);
于 2013-01-15T09:44:24.130 に答える