Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have created a windows application which retrieve data from .dat file and convert it into datagridview(as per my requirement, it splits data into columns).Now column named "Grouptype" is there. I want to create a dropdownbox in that particular column. and it should be filled with the existing data of that column.
E.g. if there are 5 different values for Grouptype column then the dropdownbox should be filled by those values. and if i add any new row and grouptype column has any new value then it should be allowed to enter.

For binding purpose i have used following code.

C#
public static SortableBindingList<User> LoadUserListFromBkpFile(string path)
        {
            var users = new SortableBindingList<User>();
            char[] delimiterChars = { '|' };
            foreach (var linedata in File.ReadAllLines(path))
            {
                string[] words = linedata.Split(delimiterChars);
                if (words.Count() < 10)
                {
                    return users;
                }
                if (words[0].Trim() != "")
                {
                    users.Add(new User
                    {
                        LineNumber = int.Parse(words[0]),
                        GroupType = words[1],
                        CountyCode = words[2],
                        County = words[3],
                        Payee = words[4],
                        Address1 = words[5],
                        Address2 = words[6],
                        City = words[7],
                        State = words[8],
                        ZipCode = words[9]
                    });
                }
            }
            return users;      
        
        }




I don't know how to add dropdownbox with this. and fill it with existing data at run time.
Posted

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