c# - Items Count of listbox on another form -


while i'm debugging, value of ex comes 0.

i can't modify or read listbox values on different form. have 2 forms here. how can resolve this?

form1 eski = new form1(); form2 yeni = new form2();  listbox array = new listbox(); int ex = eski.listbox5.items.count; (int ix = 0; ix <= ex; ix++) {     array.items.add(eski.listbox5.items[ix]); } 

the problem on code one:

form1 eski = new form1(); 

you initializing new form , code not call opened form1 running on application.

you need replace , instead:

var eski = application.openforms.oftype<form1>().singleordefault(); 

with that, can access controls want.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -