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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:29:48+00:00 2026-06-08T07:29:48+00:00

I am working on a Windows Forms application. I have two tab2 in my

  • 0

I am working on a Windows Forms application. I have two tab2 in my window form. In each tab, I build a datagridview which I named it dgvRound. I loaded two different set of datas to the two datagridview in these two tabs. When I switch from tab1 to tab2, I still see the datagridview data on the tab1. How do I change it (currency?) to see the dgvRound in tab2 which I update the datagridview with new data?

// tabView is my main tab page control
//  Add a new tab for a new round
string title = "Round " + Convert.ToString(intRound);
TabPage myTabPage = new TabPage(title);
tabView.TabPages.Add(myTabPage);

// set up datagridview box
DataGridView dgvRound = new DataGridView();
myTabPage.Controls.Add(dgvRound);
// set up the datagridview column and row headings
SetupTableView(dgvRound);

//load datagridview in a loop with different data from different dataset
string[] row1 = new string[] { "array of datas" };
dgvRound.Rows.Add(row1);

I called the above code to create the tab and dgv multiple times depending on some variables. The data in each datagrid in each tab are ok. But when I try to pull the data from datagridview (dgvRound) from tab2, i see the data in tab1 not tab2. For example:
dgvRound.Rows[0].Cells[“Game 1”].Value. How do I tell it look at tab2.dgvRound.Rows[0].Cells[“Game 1”].Value?

Thanks for your help
Daniel

Thanks HotSoft, I finally found the code to search for the current datagridview in a dynamically created tab page. I added this and it is working now.
TabPage CurrentTabPage = tabView.SelectedTab;
// Get all the controls here
Control.ControlCollection col = CurrentTabPage.Controls;
// should have only one dgv
foreach (Control myControl in col)
{
if (myControl.ToString() == “System.Windows.Forms.DataGridView”)
{
DataGridView tempdgv = (DataGridView)myControl;
tempdgv.SelectAll();
dgvRound = tempdgv;
}
}
Thanks again for your help…

  • 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-08T07:29:50+00:00Added an answer on June 8, 2026 at 7:29 am

    Given that I cannot see you code dynamically creating the DataGridView on each Tab

    Looks like you are showing the same DataGrid on both tabs with out reloading or re-binding the different datasource for datagrid’s on different tabs

    Update on OP’s comment:

    You can get the DataGridView from the tabpage like this

    DataGridView dataGridView1 = tabPage1.Controls.OfType<DataGridView>() as DataGridView;
    DataGridView dataGridView2 = tabPage2.Controls.OfType<DataGridView>() as DataGridView;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a .NET Windows Forms application. I have an event handler procedure
I'm working on a Windows Forms application, which of course involves databinding to objects.
I am developing a windows based application in .net. I have two forms. Form2
In a Windows Form application, I'm trying to create a DataGridView with two columns:
Currently I am working with: C# Windows forms application I currently have a problem
I'm working on a windows forms application (.NET 4.0). My form contains a 'Fast
I currently have a windows form application composed of a textbox and two buttons
I am working on windows forms application using c#.net. i have developed an application(3-tier)
I am working on windows forms applications using c# .net 4.0. Where I have
I'll start working on windows forms application that hosts ESRI maps into it So,

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.