c# - How to read contents of many textboxes to an array? -
i have write program (c#, wpf), data retrieved ~30 textboxes. i'd cycle textboxes through. tried create array of textboxes, didn't work because in every method had repeatedly reinitialize array.
textbox[] subjects = { textbox1, textbox2, textbox3, textbox4, textbox5, textbox6, textbox7, textbox8, textbox9, textbox10 }; textbox[] credits = { textbox11, textbox12, textbox13, textbox14, textbox15, textbox16, textbox17, textbox18, textbox19, textbox20 }; textbox[] marks = { textbox21, textbox22, textbox23, textbox24, textbox25, textbox26, textbox27, textbox28, textbox29, textbox30 }; subject.subjectname = subjects[selection].text; subject.amountofcredits= convert.toint32(credits[selection].text); subject.mark = convert.toint32(marks[selection].text);
main question is, if there other way cycle through controls without creating arrays of textboxes?
thanks in advance.
have considered using datagrid control? have 3 columns (subjects, credits , marks) , selected record via selecteditem property?
the other option use itemscontrol. style itemtemplate have 3 textboxes, databind properties of subject directly. itemscontrol's itemssource bound observable collection of subjects. more information on how this, go microsoft's on data templating overview.
Comments
Post a Comment