c# - how to change code to retrieve particular column in datagridview? -



c# - how to change code to retrieve particular column in datagridview? -

i have list of info in datagridview. example, 1 column named class (each row has different value, see below), possble have combo box, contains of possible record class values in combo box? *it should have list of 6a, 6b, 6c if more classes added database later (example 6d), these should in 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 code found, how alter 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 combobox combobox1.datasource = resultlist;

if windows forms app can create class, similar to

class obj { public string class { get; set; } public string info { get; set; } }

then create list of objects:

var list = new list<obj>(); list.add(new obj() { class = "6a", info = "jane,14 may 1980;mary,4 june 1980;" }); // go on adding list here

and

combobox1.datasource = list; combobox1.displaymember = "class";

and hook combobox1.selectedindexchanged event , grab combobox1.selecteditem, cast obj , you're good.

c# winforms datagridview

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -