Cieja Cieja - 2 months ago 27
C# Question

Change textbox to dropdown

How can I change text box with a dropdown in Infragistics?

I have a reference to UltraGridCell myCell.

I see that there is a method for the cell but it doesn't work.

myCell.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;

Do you know how can I handle this problem?

Answer Source

In order to show the cell as a drop down you have to set its ValueList property and set the Style to DropDown or DropDownList.

You can create a value list with

var vl = new ValueList();
vl.ValueListItems.Add("Item 1");
vl.ValueListItems.Add("Item 2");
vl.ValueListItems.Add("Item 3");

and then set it to either the cell or the column, depending on whether it should be valid for all cells or just a particular one

myCell.ValueList = vl;
myColumn.ValueList = vl;

If you require the data value of the item to be different than the displayed text you can use the overload of Add that takes and object and a string, i.e.

vl.ValueListItems.Add(1234, "Item 1");

Then the displayed text would be Item 1 but the value in the cell would be 1234