ComboBox in Ultragrid
-
13-09-2019 - |
Frage
Ich habe einige Wartungsarbeiten auf einem alten VB.NET Anwendung (Visual Studio 2003) zu tun, die Infragistics NetAdvantage 2006.
verwendetIch brauche eine Spalte zu einem vorhandenen Ultragrid-Steuerelement hinzuzufügen. Diese neue Spalte wie ein ComboBox handeln muß, so dass die Auswahl aus einer Liste von Werten.
Ich habe die neue Spalte, und legen Sie den Stil auf DropDownValidate. Ich habe einen Valuelist und zugewiesen an die neue Spalte.
Zur Laufzeit bekomme ich nicht die erwarteten Ergebnisse. Was bin ich?
Lösung
So etwas sollte für Sie arbeiten:
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;
Andere Tipps
Dieser Code funktioniert für mich:
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;.
Ich lasse generell den Stil als Standard.