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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:55:25+00:00 2026-05-27T04:55:25+00:00

This question is related to one I asked earlier: Adding buttons to a TabControl

  • 0

This question is related to one I asked earlier:

Adding buttons to a TabControl Tab in C#

In short: I have programmatically added controls to tabs in a c# form.

I would now like to access the tab’s controls (in this case a DataGridView) and set some values.

this.dataGridView1.Rows[r].Cells[1].Value = "General";

Above is how I have done it before, but I can’t use this right now due to scope, so I need to access the DataGridView via the parent:

// THIS IS NON WORKING CODE NO COMMENTS ABOUT THE SYNTAX PLEASE
languageTabs.TabPages[0].Controls["grid"].Row[int].Cells[int].Value = "General";

// TabControl -> First Tab -> DataGridView -> the column -> row -> set value

Is there a way to do the same functionality of the first code snippet, but using the parents like in the second snippet?


EDIT:

Here is some more code if it helps:

 while ((line = stringReader.ReadLine()) != null)
                {
                    //if the line isn't a comment (comments start with an '/')
                    if (line[0] != '/')
                    {
                        // split the string at each tab
                        string[] split = line.Split(new char[] { '\t' });

                        // is this line the "blah"?
                        if (split[0] == "blah")
                        {
                            // we now need to set up the tables to be used
                            for (int i = 1; i < split.Length; i++)
                            {
                                // add a tab for each language
                                string tabTitle = split[i];
                                newTab = new TabPage(tabTitle);
                                newTab.Name = tabTitle;
                                languageTabs.TabPages.Add(newTab);

                                // add a DataGridView to each tab
                                grid = new DataGridView();
                                grid.SetBounds(14, 68, 964, 420);
                                grid.Name = tabTitle + "Grid";

                                // set the columns in the DataGridView
                                stringIdColumn = new DataGridViewTextBoxColumn();
                                stringIdColumn.HeaderText = "String ID";
                                stringIdColumn.Width = 75;
                                stringIdColumn.Name = tabTitle + "StringIDColumn";
                                grid.Columns.Insert(0, stringIdColumn);

...

...

// add the DataGridView and button to each tab
                                languageTabs.TabPages[split[i]].Controls.Add(grid);
    }
}
 else
                        {
                            // this isn't the identifier it must be the start of the languages
                            // load the strings to the tables
                            // THIS IS WHERE I WANT MY CODE
                        }
  • 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-27T04:55:26+00:00Added an answer on May 27, 2026 at 4:55 am

    This is how I got it working:

    Control[] ctrls = languageTabs.TabPages[1].Controls.Find("EnglishGrid", true);
                                if (ctrls[0] != null)
                                {
                                    DataGridView dgv = ctrls[0] as DataGridView;
                                    dgv.Rows[r].Cells[0].Value = 1;
                                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is related to an earlier question I asked. I'm adding a toString() method
I have question quite much related to this one I asked a while ago
This question is related with one of my earlier questions.. Previous Post In there
This question is related to this one . I have a page table with
Another question related to this one . I have a List<SortableObjects> that is the
I have a question related to this one . I don't want to do
I have a question related to this one : I'm trying to attach an
This is a related question to one I posted earlier... I'm trying to sum
This question is related to one I asked previously, see here . As a
This question is similar to the one i asked here . But its related

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.