I have 2 grids on two separate forms. Both are bound to the same type. I have a helper method that configures a column to be a drop down.
It works in one grid and not the other.
The column in the grid where it is not working is clearly binding to the data in the data source because the values are correct. It is just not showing as a drop down.
If I add an unbound column to the grid and configure it as a drop down the code works (see below):
const string TEST_VALUE = "DropdownTest"; ValueList vl = null; if(!Grid.DisplayLayout.ValueLists.Exists(TEST_VALUE)) { vl = Grid.DisplayLayout.ValueLists.Add(TEST_VALUE); vl.ValueListItems.Add("Red"); vl.ValueListItems.Add("Green"); vl.ValueListItems.Add("Blue"); } if(!columns.Exists(TEST_VALUE)) { UltraGridColumn dropdown = columns.Add(TEST_VALUE); dropdown.ValueList = vl; dropdown.CellActivation = Activation.AllowEdit; dropdown.CellClickAction = CellClickAction.Edit; dropdown.Style = ColumnStyle.DropDownList; dropdown.Header.Caption = "Lol whut?"; }
What could possibly be interfering with displaying the drop down for this column? I feel like I have checked everything...
Is the column editable? Can you type into it? The cell will not drop down unless editing is enabled, so if you have disabled editing (or your data source does not allow editing that particular field), it will not drop down.
Does the DropDown button display in the cells and just not work? Or does it not show up at all?
Thanks for your reply Mike. It turns out the list I was using for the data source was derived from CSLA ReadOnlyListBase. Calling ToList() on the read one makes the drop down appear. The objects in the list are editable and the same that were there in the 'read only' version however. What constitutes a read only list to the UltraGrid?
Well, just to be clear, it's not the dropdown list that needs to be editable, it's the cells in the grid. If are you able to enter edit mode on the grid cell and type into it to change the value, then it's editable. If you can't, then it's not editable and the dropdown cannot be displayed.
You can, of course, disable editing for the grid, column, row, or cell using various properties on the grid. But assuming you are not doing that, then the field in the data source can be ReadOnly, as well.
I'm not familiar with CSLA ReadOnlyListBase, but if you are using that as your grid's DataSource and it doesn't allow editing of the data, then the grid obviously can't edit the data, either. And therefore, the grid won't be able to show a dropdown. So if you need users to be able to drop down a list or edit the cells in the grid, you have to use a DataSource that allows editing.
BTW... I assume ToList() return a List or List<T> and that's generally not a great data source to use for a grid. List<T> doesn't send notifications for things like adding or deleting rows. So it's better to use a BindingList<T> or something that implements IBindingList.
CSLA's ReadOnlyListBase and the List<T> I converted it to both had the same objects in it. I am wondering what criteria Infragistics components (like the grid here) look for to determine whether a data source is read only or not. Is there some standard interface or something?