Click here to Skip to main content
15,885,141 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am using a datagridview property..

in datagridview i use 3 columns namely name(string), type(combobox), Age(string)..

in combobox , the items are Male, Female
By default,i get

1.Name
Vino
2.Type

3.Age
22

i need to show the datagridview combobox's 0th index value as default ..

Required,

1.Name
Vino
2.Type
Male
3.Age
22



Please help me to get the datagridviewcolumnindex dyamiclly when load....
Posted
Updated 19-Jun-13 21:27pm
v2
Comments
Mahesh Bailwal 20-Jun-13 3:33am    
By default which value is coming selected?
Sunasara Imdadhusen 20-Jun-13 9:10am    
Where is your code?
AlphaDeltaTheta 21-Jun-13 3:30am    
Some code please...

give your sample code..
or
Try to give Male as your Text/NullText in combobox
 
Share this answer
 
In RowAdded event of datagrid try this code.

C#
DataGridViewComboBoxCell cell = dataGridView1.Rows[e.RowIndex].Cells[1] as DataGridViewComboBoxCell;

if (cell != null)
{
       cell.Value = cell.Items[0];
}


Hope it help you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900