Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Combo In DataGridView - Part 2
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01443811
Message ID:
01443982
Vues:
23
>>>I have successfully added a combox to a DataGridView:
>>>
>>>
>>>DataGridViewComboBoxColumn colType = new DataGridViewComboBoxColumn();
>>>colType.HeaderText = "Total";
>>>colType.DropDownWidth = 90;
>>>colType.Width = 90;
>>>colType.MaxDropDownItems = 15;
>>>grdColumnInfo.Columns.Insert(0, colType);
>>>colType.Items.AddRange("", "Calc", "No Calc", "Pending");
>>>grdColumnInfo.Columns[7].DataPropertyName = "Total";
>>>
>>>
>>>In my SQL table is a column called Total. How do I set this combo to show the value from SQL?
>>
>>Try setting the DataPropertyName directly on colType:
colType.DataPropertyName="Total"
>>Check this:http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcolumn.datapropertyname.aspx
>
>This throws
>
>---------------------------
>DataGridView Default Error Dialog
>---------------------------
>The following exception occurred in the DataGridView:
>System.ArgumentException: DataGridViewComboBoxCell value is not valid.
>To replace this default dialog please handle the DataError event.
>
Sounds like a bit of debugging is called for.
One reason might be that the value for 'Total' in the table is not one of the items available to the ComboBox ("Calc", "NoCalc") etc.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform