2009-06-12 72 views
1

我要做的老VB.NET應用程序(Visual Studio 2003中)使用的Infragistics的NetAdvantage 2006年組合框中的UltraGrid

我需要一列添加到現有的UltraGrid控制一些維護。這個新列必須像ComboBox一樣工作,允許從值列表中進行選擇。

我添加了新列,並將Style設置爲DropDownValidate。我創建了一個ValueList並將其分配給新列。

在運行時,我沒有得到預期的結果。我錯過了什麼?

+0

如果答案下面不適合你做,你可能要指定您所期望的結果和實際結果被接收。 – 2009-06-13 20:09:45

回答

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; 
1

此代碼的工作對我來說:

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;

我通常會將此樣式作爲默認值。