我必须对一个使用NetAdvantage 2006的旧VB.NET应用程序(Visual Studio2003)进行一些维护。
我需要向现有的UltraGrid控件添加一列。这个新列的作用必须类似于ComboBox,允许从值列表中进行选择。
我添加了新列,并将样式设置为DropDownValidate。我创建了一个ValueList并将其分配给新列。
在运行时,我得不到预期的结果。我遗漏了什么?
发布于 2009-06-13 20:06:05
这样的东西对你来说应该是有效的:
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-12 21:26:19
下面的代码适用于我:
ultraGridValueList.ValueListItems.Add("ValueMemeber1","DisplayMemeber1");ultraGridValueList.ValueListItems.Add("ValueMemeber3","DisplayMemeber2");ultraGridValueList.ValueListItems.Add("ValueMemeber4",“DisplayMemeber2”);ultraGridValueList.ValueListItems.Add(“ValueMemeber4”,"DisplayMemeber4");
ultraGrid1.DisplayLayout.Bands.Columns"myDropDownCol".ValueList = ultraGridValueList;
我通常将样式保留为默认样式。
https://stackoverflow.com/questions/987167
复制相似问题