I'm new using infragistics so this might be a simple question, so here goes:I have a UltraGridColumn that has style of ColumnStyle.DropDownList. The column ValueList is set to a BindableValueList. All this is wired up in the InitLayout event method.void ultraGrid_InitializeLayout(object sender, InitializeLayoutEventArgs e) Once that method completes, I have a dropdown with values as expected.Now the goal is to remove specific items from the dropdown list when user clicks it. I added this
ugc.Editor.BeforeEnterEditMode += Editor_BeforeEnterEditMode;
to the InitLayout event methodWhen this method - void Editor_BeforeEnterEditMode(object sender, CancelEventArgs e) is called, I create a new BindableValueList & BindingSource. I wire up those two objects like this: UltraGridColumn ugc =ultraGrid.DisplayLayout.Bands[0].Columns[this.dataSet.dataTable.CLASS_IDColumn.ColumnName];
var bvl = new BindableValueList();
var bs = new BindingSource(components);
bs.DataSource = this.dataSet;
bs.DataMember = this.dataSet.dataTable.TableName;
bs.Filter = "RETIRED = 'N'";
bvl.DisplayMember = this.dataSet.dataTable.NAMEColumn.ColumnName;
bvl.ValueMember = this.dataSet.dataTable.CLASS_IDColumn.ColumnName;
bvl.SortStyle = ValueListSortStyle.Ascending;
bvl.BindingContext = BindingContext;
bvl.DataSource = bs; ugc.Style = ColumnStyle.DropDownList; ugc.ValueList = bvl;
The problem is this: When the Editor_BeforeEnterEditMode completes, the value in the cell changes from the Name field value to the ClassId value. It only changes for an item that has a value of IS_RETIRED. It is as if I reversed the BindableValueList display and value member.The overall goal here is to remove specific items from the dropdown list so user cannot select that value again.For example I have a item that was already added to the grid that has a value of IS_RETIRED = 'Y'. I don't want to remove this value from the existing list of items in the grid, however I want to make sure that when user attempts to edit, items that have a value of IS_RETIRED = 'Y' are removed from the list so they cannot be selected.Hope that makes sense, thanks for the input
Hi Galahad,
I don't think the approach you are taking here is going to work. The ValueList in this case is translating DataValue to DisplayText in the grid cell. This conversion doesn't just happen when the cell is in edit mode, it happens all the time, every time the cell paints. So by changing the ValueList and removing items, you are breaking the translation for other cells.
So you need to keep the entire ValueList intact all the time.
What I would do, instead is use UltraCombo or UltraDropDown instead. You could bind o the same data source you are using now - but just keep the list populated with all possible values. Then you can filter the list to only show valid items when the user drops it down.
Thanks for the fast response. Your answer makes perfect sense. So bear with me pls, if I understand you correctly I need to first make change to UltraGrid_InitializeLayout method by creating new instance of UltraCombo as shown below:
UltraGridColumn ugc = e.Layout.Bands[0].Columns[this.DataSet.DataTable.JOB_CLASS_IDColumn.ColumnName]; UltraCombo uc = new UltraCombo();
BindingSource bs = new BindingSource(this.DataSet, this.DataSet.DataTable.TableName);
uc.BindingContext = this.BindingContext; uc.DisplayMember = this.DataSet.DataTable.NAMEColumn.ColumnName; uc.ValueMember = this.DataSet.DataTable.CLASS_IDColumn.ColumnName; uc.DataSource = bs; ugc.EditorComponent = uc;This gives me the ultra combo rendered as expected.Where I'm a little confused is how I filter the list when the Editor_BeforeEnterEditMode event method is called.I cast my sender in the Editor_BeforeEnterEditMode method as UltraGridComboEditor, see below:void Editor_BeforeEnterEditMode(object sender, CancelEventArgs e) { UltraGridComboEditor combo = sender as UltraGridComboEditor;However when I try to get to the combo valuelist to remove what I want, I cannot access it...what am I missing here?