Click here to Skip to main content
15,895,801 members
Please Sign up or sign in to vote.
3.67/5 (2 votes)
I am new in windows application. In my Datagridview i have 3 comboBox Country,State,City. Based on Country, State need to load, Based on State City Need to Load.Give Sample Example.

Thanks For Advance
Posted
Updated 24-Feb-12 17:06pm
v2

C#
var newColumn = new DataGridViewComboBoxColumn() {
    Name = "abc"
};
newColumn.DataSource = new string[] { "a", "b", "c" }; 
dgv.Columns.Add(newColumn);


However, now I would like to trim the list for certain rows. I'm trying to set the list per row like this:

C#
foreach (DataGridViewRow row in dgv.Rows) {
    var cell = (DataGridViewComboBoxCell)(row.Cells["abc"]);
    cell.DataSource = new string[] { "a", "c" };
}
 
Share this answer
 
v3
Inside DataGridview need load Country,state and city.
 
Share this answer
 
Have a look at the DataGridViewComboBoxColumn class[^]. Cascading dropdowns might help you create a selection where you can choose country, state and city.
 
Share this answer
 
Comments
Аslam Iqbal 25-Feb-12 0:50am    
nice lnk. my 5
Abhinav S 25-Feb-12 0:50am    
Thank you Aslam.
Аslam Iqbal 25-Feb-12 0:52am    
you are welcome.....:)

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