I have a list of data in datagridview. For example, one column is named Class (each row has a different value, see below), is it possble that to have a combo box, that contains all of the possible record Class values in the combo box? *It should be have a list of 6A, 6B, 6C
If more classes are added to the database later (example 6D), these should also be in the combobox.*
A view of datagridview
Class Name
6A Jane,14 May 1980;Mary,4 June 1980;
6B leen, 31 May 1980; Peter 6 Jan 1980;
6C Eillen, 19 Aug 1980; Yvwon, 28 Mar 1980;
6D Evan, 24 Dec 1980; Ivan, 20 Nov 1980;
Here is the code i found, but how do I change it to what i want?
var input = Convert.ToString(datagridview1.CurrentRow.Cells[0].Value);
var resultList = Regex.Matches(input, **@".*?,(.*?),.*?;")**
.Cast<Match>()
.Select(arg => arg.Groups[1].Value)
.ToList();
// bind to a combobox
comboBox1.DataSource = resultList;
If this is a Windows Forms app then you can create a class, similar to
then create a list of objects:
and then
And finally hook your
comboBox1.SelectedIndexChangedto an event and grab thecomboBox1.SelectedItem, cast it to Obj and you’re good.