如何选择默认值Ultragrid列单元格下拉列表

时间:2017-07-13 10:48:54

标签: c# .net winforms ultrawingrid

我已加载Ultra Grid并使用设置New Column Cell List 以下代码:

UltraGridColumn column = this.ultraGrid1.DisplayLayout.Bands[0].Columns[1];

// Create a value list.
ValueList vl1 = new ValueList( );
vl1.ValueListItems.Add( 1, "True" );
vl1.ValueListItems.Add( 2, "False" );

// Set vl1 to the column2. Cells in column2 will use this value list.
column.ValueList = vl1;

我想要vl1.selectedvalue = 2加载默认值,这是我无法实现的。非常感谢任何帮助和指导。

enter image description here

1 个答案:

答案 0 :(得分:0)

http://help.infragistics.com/Help/Doc/WinForms/2011.2/CLR2.0/html/Infragistics2.Win.v11.2~Infragistics.Win.ValueList~SelectedIndex.html

您需要设置ValueList的SelectedIndex:

ValueList list = new ValueList();
list.ValueListItems.Add(1,"One");
list.ValueListItems.Add(2,"Two");
list.ValueListItems.Add(3,"Three");
list.ValueListItems.Add(4,"Four");

list.SelectedIndex = 2;
list.SortStyle = ValueListSortStyle.AscendingByValue ;
this.ultraGrid1.DisplayLayout.Bands[0].Columns[0].ValueList = list;

我希望这会有所帮助。