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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:05:11+00:00 2026-06-11T04:05:11+00:00

I am new to C# and programming in general and trying to learn/practice a

  • 0

I am new to C# and programming in general and trying to learn/practice a bit before starting classes in spring. Anyway I am trying to get the Tag of a checkbox control from Form A to Form B into a textbox on FormB (using string builder because there is other information from textboxes going to FormB Textbox as well) Now i can get this to work fine on Form B load but due to how my program flows i need to make this happen on a button click. Below is the current code that is working on FormB load. Sorry if i am missing something basic here.

Form B. I omitted some of my stringbuilder lines for space.

   public CodeBlueForm(List<string> ids, string custNameCb, string custWtnCb, string custCbrCb, string custNotesCb)
    {
        InitializeComponent();

        cbNameText.Text = custNameCb;
        cbWtnText.Text = custWtnCb;
        cbCbrText.Text = custCbrCb;
        cbNotesText.Text = custNotesCb;
        string checkBoxesLines = "Lights: ";
        foreach (string id in ids)
            checkBoxesLines += string.Format("{0}, ", id);
                System.Text.StringBuilder strBuilder = new System.Text.StringBuilder();
            strBuilder.AppendLine("Inet Notes: " + "\r" + ((checkBoxesLines) + cbNotesText.Text));

            cbViewText.Text = strBuilder.ToString();
        {

My current Form A

private void code_blue_link_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
    {
        var checkBoxIds = GetCheckBoxIds();

        tShootCb = tShootText.Text;
        svcsOfferedCb = svcsOfferedText.Text;
        otherNotesCb = otherNotesText.Text;
        custModemCb = custModemText.Text;
        //Opens CODE BLUE form and pushes text to it.
        CodeBlueForm cbForm = new CodeBlueForm(checkBoxIds, custNameText.Text, custCbrText.Text, custBtnText.Text, custModemCb + "\r\n" + tShootCb + "\r\n" + svcsOfferedCb + "\r\n" + otherNotesCb);

        cbForm.Show();

    }
    private List<string> GetCheckBoxIds()
    {
        List<string> checkBoxIds = new List<string>();
        foreach (Control control in pnlCheckBoxes.Controls)
        {
            if (control is CheckBox)
            {
                CheckBox checkBox = (CheckBox)control;

                if (checkBox.Checked && checkBox.Tag is string)
                    checkBoxIds.Add((string)checkBox.Tag);
            }
        }
        return checkBoxIds;

As i said this currently does work on Form B load but i need to figure out how to make it work in FormB button click. Any direction on this would be great.

Thanks

  • 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-11T04:05:12+00:00Added an answer on June 11, 2026 at 4:05 am

    You can pass a handle of FormA to FormB upon creation. All items that are on your FormA can then be accessed in FormB using that handle.

    public class FormA : Form
    {
        public FormA()
        {
            InitializeComponent();
        }
    
        public void buttonClick(object sender, EventArgs e)
        {
            FormB formB = new FormB(this);
            formB.Show();
        }
    }
    

    and

    public class FormB : Form
    {
        private FormA parent;
    
        public FormB(FormA parent)
        {
            InitializeComponent();
            this.parent = parent;
        }
    
        public void buttonClick(object sender, EventArgs e)
        {
            myTextBox.Text = parent.myCheckBox.Text;
        }
    }
    

    In this example you have a checkbox called myCheckBox on FormA, a textbox called myTextBox on FormB and a button on each form. Each button has a method called buttonClick registered to the click event. The button on FormA creates and shows an instance of FormB and passes along a handle to itself (this). The button on FormB can then use the handle (called parent in this example) to access all controls on FormA IFF you made them accessible by changing the Modifiers property to public. (This is not a nice way to do it, but for the sake of simplicity I’d recommend to do it in that way for now. Once you understand the dependencies you should move on the create public getter/setter methods to encapsulate exactly what should be changed instead of exposing the whole control.)

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

Sidebar

Related Questions

I'm new to programming in general and currently trying to get a foot into
Disclaimer: I'm trying to learn proper OO programming/design, so I'm pretty new to this
I'm very new to jquery and programming in general but I'm still trying to
I'm new to C++ and programming in general . I'm trying out small programs
I am new to Haskell, and programming in general. I am trying to define
I'm new to both Ruby and programming in general. I've been trying to put
New to Linux programming in general. I am trying to communicate with a kernel
I'm new to PHP and MySQL (and programming in general) and I'm trying to
New to android here, (and programming in general) I'm following this example trying to
I'm rather new to Assembly (And programming in general, to be honest). I'm trying

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.