1

我必须对使用 Infragistics NetAdvantage 2006 的旧 VB.NET 应用程序 (Visual Studio 2003) 进行一些维护。

我需要向现有的 UltraGrid 控件添加一列。这个新列必须像 ComboBox 一样,允许从值列表中进行选择。

我添加了新列,并将样式设置为 DropDownValidate。我创建了一个 ValueList 并将其分配给新列。

在运行时,我没有得到预期的结果。我错过了什么?

4

2 回答 2

6

像这样的东西应该适合你:

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;
于 2009-06-13T20:06:05.070 回答
1

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.

于 2009-06-12T21:26:19.177 回答