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 8406809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:12:48+00:00 2026-06-09T23:12:48+00:00

I am trying to create some type of list of controls for multiple objects.

  • 0

I am trying to create some type of list of controls for multiple objects. The object is for a pattern displayed on a screen and has several different attributes such as duration, offset, next pattern, pattern index. I would like to be able to create an iterable list of controls so I can easily set the different attributes of each pattern in my GUI. Here is a rough draft of the form I’m creating. Here is a link to the form i’m creating.

enter image description here

Each line is a collection of attributes for a pattern. I would like to be able iterate through each one of those lines in the code somehow and set the attributes of each pattern based off of the user input. From what I’ve read so far I think I want to use an ItemsControl tool and somehow bind it to the GUI, but I’m not really sure how to do that or if that is what I should do. What I’m using now is a TableLayoutPanel with multiple Panels, but it doesn’t seem that there is much control in these tools. How should I group the controls of each line together and then iterate through each line efficiently?

  • 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-06-09T23:12:50+00:00Added an answer on June 9, 2026 at 11:12 pm

    Okay I think I have achieved what you were going for Sport, I know WPF better than WinForms, but here is my solution that I just “self-taught” myself.

    I’m going to assume there won’t be any problems with doing this in your solution.

    First create a User Control. I did a Right Click on my WinForm project > Add > User Control. This is where you’re going to be adding the content that make up the rows. So it should look like this, and I named my user control RowContent:

    Control

    Make sure you have your name your controls. So for the check box, I named it stprIndex_chkBox, enable_chkBox and so on.

    Now you need to implement the functionality you want for each of the controls using. So, you’re going to want to change the value of your stprIndex_chkBox.Text, and the enable_chkBox.Checked for starters. You’re also going to want to access the Values of you numericalUpDowns. So in RowContent.cs I added getters and setters depending on the data I needed from the form. So here is a snippet of the accessors (remember you will want to add more):

    public partial class RowContent : UserControl
    {
        public RowContent()
        {
            InitializeComponent();
        }
    
        public string SetChkBox1Text
        {
            set { stprIndex_chkBox.Text = value; }
        }
    
        public bool IsEnabledChecked
        {
            get { return enable_chkBox.Checked; }
        }
    }
    

    Now you see, these will allow you access of the variables outside the RowContent class. Let’s move on to the TablePanelLayout control.

    I created an additional User Control the same way I created RowContent, but this time I named it ContentCollection. I set AutoSize of the User Control to true and dropped TableLayoutPanel ( named tableLayoutPanel1 ) onto it.

    For the sake of saving time, I added all the controls into the rows dynamically like this:

    public partial class ContentCollection : UserControl
    {
        public ContentCollection()
        {
            InitializeComponent();
            RowContent one = new RowContent();
            RowContent two = new RowContent();
            RowContent three = new RowContent();
            RowContent four = new RowContent();
            RowContent five = new RowContent();
            RowContent six = new RowContent();
            tableLayoutPanel1.Controls.Add(one);
            tableLayoutPanel1.Controls.Add(two);
            tableLayoutPanel1.Controls.Add(three);
            tableLayoutPanel1.Controls.Add(four);
            tableLayoutPanel1.Controls.Add(five);
            tableLayoutPanel1.Controls.Add(six);
            tableLayoutPanel1.SetRow(one, 0);
            tableLayoutPanel1.SetRow(two, 1);
            tableLayoutPanel1.SetRow(three, 2);
            tableLayoutPanel1.SetRow(four, 3);
            tableLayoutPanel1.SetRow(five, 4);
            tableLayoutPanel1.SetRow(six, 5);
        }
    }
    

    This gives me:

    enter image description here

    Now here you can see we are adding these things dynamically. I hope you can picture how to “customize” this User Control when you’re using it in your WinForm. In this same file you’re going to want to add some more Getters/Setters/functions depending on what you want to do just like the other User Control; so, AddAdditionalRow(RowContext rc) and so on. I actually cheated and changed the tableLayoutPanel to be public to make this quicker in the end.

    So finally, you have your ContentCollection that will hold your custom object, now you need to add it to your Form.

    Go to your Form, open up your Toolbox and scroll to the top to see your Form there! Drag and drop it on your main form and vio’la. Now, to iterate through the RowContent, it is fairly easily. Since I drag and dropped my User Control onto the Form, I was able to name it (userControl12) and start accessing the controls right away. Check out how I add check marks to every other checkbox and dynamically change the Stepper Index:

    public partial class Form1 : Form
    {
        static int i = 0;
        public Form1()
        {
            InitializeComponent();
            foreach (RowContent ctrl in userControl11.tableLayoutPanel1.Controls)
            {
                ctrl.SetChkBox1Text = i.ToString();
                if (!ctrl.IsEnabledChecked && i % 2 == 0)
                    ctrl.IsEnabledChecked = true;
                i++;
            }
            foreach (RowContent ctrl in userControl12.tableLayoutPanel1.Controls)
            {
                ctrl.SetChkBox1Text = i.ToString();
                i++;
            }
        }
    }
    

    enter image description here

    I’m not claiming this to be the best design out there… because it isnt, but it illustrates how to do such a thing. Let me know if you have any questions.

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

Sidebar

Related Questions

My friend is trying to create a utility function that is given some Type
Im trying to create a list of strings using some recursion. Basically i want
I am trying to create something like a list. However, different instances of the
I'm trying to learn some smalltalk programming.... I'm trying to create a list of
I am trying to create some capacity planning reports and one of the requrements
So I'm trying to create some graphs using Core Plot, but for the following
I am trying to create some reusable components in Silverlight2 . The difficulty comes
I am trying to create some charts of data (eg http://www.amibroker.com/ ). Is there
I am trying to create some rules and facts on a certain situation. The
I am trying to create some global variables in a firefox extension. In my

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.