Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7630107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:00:53+00:00 2026-05-31T06:00:53+00:00

I have to write a program (C#, WPF), where data is retrieved from ~30

  • 0

I have to write a program (C#, WPF), where data is retrieved from ~30 TextBoxes. I’d like to cycle the textboxes through. I tried to create an array of textboxes, but it didn’t work very well because in every method I had to repeatedly reinitialize this 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 is any other way to cycle through all those controls without creating arrays of textboxes?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T06:00:54+00:00Added an answer on May 31, 2026 at 6:00 am

    Have you considered using a DataGrid control? You could have three columns (Subjects, Credits and Marks) and easily get to the selected record via the SelectedItem property?

    The other option is to use an ItemsControl. You could style the ItemTemplate to have three textboxes, which you databind to the properties of Subject directly. The ItemsControl’s ItemsSource would then be bound to an observable collection of Subjects. For more information on how to do this, go to Microsoft’s help on Data Templating Overview.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to write a program that read from a file that contains the
Imagine we have a program trying to write to a particular file, but failing.
i have to write program, which will create two child processes These processes would
I have an array of structs I would like to write to a binary
I have to write program that create process using pipe() . My first task
I have to write program that gets a number n from the user, and
I want to write a program in WPF but not sure should I target
I have to write a program that sniffs network packets (part1-the simple part). And
I have been asked to write a program using python for an assignment. I
I have been assigned wit the task to write a program that takes a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.