c# - Adding List<object> to listBox (form2 to form1) -
this question has answer here:
- communicate between 2 windows forms in c# 10 answers
i want transfer data form2
form1
's listbox1
. form2
includes several textboxes,
i have tried face problem placing of code form1
cannot values needed form2
.
can help, understand i'm not clear can answer questions code.
private void button3_click(object sender, eventargs e) { list<form1other> filelist = new list<form1other>(); form1other[] f1other = new form1other[10]; form1 testform1 = new form1(); string tname = textbox1.text; string tdesc = textbox2.text; decimal tprior = numericupdown1.value; string tdate = datetimepicker1.value.toshortdatestring(); string tcompl = "unfinished"; filelist.add(new form1other(tname, tdesc, tprior, tdate, tcompl)); testform1.listbox1.items.add(filelist[0].tname); testform1.listbox1.items.add(filelist[0].tdesc); testform1.listbox1.items.add(filelist[0].tprior); testform1.listbox1.items.add(filelist[0].tdate); testform1.listbox1.items.add(filelist[0].tcompl); system.diagnostics.debug.writeline(filelist[0].tdesc);
you need sort of messaging/event mechanism can communicate across different views/forms.
you either need implement own using queue , publish/subscribe. system.messaging
or use 1 implemented.
a few note use are:
Comments
Post a Comment