I have to do some maintenance on an old VB.NET application (Visual Studio 2003) that uses Infragistics NetAdvantage 2006.
I need to add a column to an existing UltraGrid control. This new column must act like a ComboBox, allowing the selection from a list of values.
I added the new column, and set the Style to DropDownValidate. I created a ValueList and assigned it to the new column.
At run-time I don't get the expected results. What am I missing?
Something like this should work for you:
var dataTable = new DataTable( "Table1" );
dataTable.Columns.Add( "Column1" );
dataTable.Rows.Add( dataTable.NewRow() );
ultraGrid1.DataSource = dataTable;
var valueList = new ValueList();
valueList.ValueListItems.Add( "dataValue1" , "displayText1" );
valueList.ValueListItems.Add( "dataValue2" , "displayText2" );
valueList.ValueListItems.Add( "dataValue3" , "displayText3" );
ultraGrid1.DisplayLayout.Bands[0].Columns[0].ValueList = valueList;
// Setting the ColumnStyle to DropDownList ensures that the user will not
// be able to type in the cell (exclude this line if you want to allow typing)
ultraGrid1.DisplayLayout.Bands[0].Columns[0].Style = ColumnStyle.DropDownList;
// Setting the ButtonDisplayStyle to Always ensures that the UltraGridColumn
// always displays as a ComboBox and not just when the mouse hovers over it
ultraGrid1.DisplayLayout.Bands[0].Columns[0].ButtonDisplayStyle = Infragistics.Win.UltraWinGrid.ButtonDisplayStyle.Always;
This code works for me:
ultraGridValueList.ValueListItems.Add("ValueMemeber1", "DisplayMemeber1"); ultraGridValueList.ValueListItems.Add("ValueMemeber2", "DisplayMemeber2"); ultraGridValueList.ValueListItems.Add("ValueMemeber3", "DisplayMemeber3"); ultraGridValueList.ValueListItems.Add("ValueMemeber4", "DisplayMemeber4");
ultraGrid1.DisplayLayout.Bands[0].Columns["myDropDownCol"].ValueList = ultraGridValueList;
I generally leave the style as default.