UltraGrid中的组合框 [英] ComboBox in UltraGrid
问题描述
我必须对使用Infragistics NetAdvantage 2006的旧VB.NET应用程序(Visual Studio 2003)进行一些维护.
I have to do some maintenance on an old VB.NET application (Visual Studio 2003) that uses Infragistics NetAdvantage 2006.
我需要在现有的UltraGrid控件中添加一列.此新列必须像ComboBox一样,允许从值列表中进行选择.
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.
我添加了新列,并将Style设置为DropDownValidate.我创建了一个ValueList并将其分配给新列.
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;
这篇关于UltraGrid中的组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!