c# - Manipulating a list with dynamically created controls -


let's say, have list<person> people, person class containing 3 strings: name, surname , age. have 6 dynamically created textbox controls, placed on panel control, , have name assigned them using for loop. as, dynamically created textchanged event said textbox controls. list consists of 2 entries people.add(new person { name = john, surname = johnson, age = 25 }); , people.add(new person { name = jack, surname = jackson, age = 30 });. need user able change list<person> entries, inputting text in corresponding textbox. so, first textbox changes people[0].name, second - people[0].surname, third - people[0].age, fourth - people[1].name, , on...

have @ textbox tag property, should here. https://msdn.microsoft.com/en-us/library/system.windows.forms.control.tag(v=vs.110).aspx

you'd store person object in tag, , when textbox updated, can update tag object in turn update list you. you'd need way of telling textbox (firstname, lastname age etc) achieved name.

a better way of doing though custom control textboxes pre-build etc understand on-the-fly building of ui needed.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -