Question

Je dois faire un peu d'entretien sur une ancienne application VB.NET (Visual Studio 2003) qui utilise Infragistics NetAdvantage 2006.

Je dois ajouter une colonne à un contrôle UltraGrid existant. Cette nouvelle colonne doit agir comme un ComboBox, ce qui permet la sélection d'une liste de valeurs.

J'ai ajouté la nouvelle colonne, et changer le style de DropDownValidate. J'ai créé un ValueList et lui a attribué à la nouvelle colonne.

Lors de l'exécution, je ne reçois pas les résultats escomptés. Qu'est-ce que je manque?

Était-ce utile?

La solution

Quelque chose comme cela devrait fonctionner pour vous:

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;

Autres conseils

Ce code fonctionne pour moi:

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

Je laisse généralement le style par défaut.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top