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

  • Home
  • SEARCH
  • 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 9172821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:26:41+00:00 2026-06-17T16:26:41+00:00

I have a project with a form with 3 tabs, each contains 1 datagridview.

  • 0

I have a project with a form with 3 tabs, each contains 1 datagridview. I disabled multiselect and can only select a row.

I need to Add new data rows or Modify rows of datas from these three datagrids, so I have a MenuStrip on top of the window with a menu with a “Add”, “Modify” and “Delete Selected Row” options.

How do I know which row is currently being selected in the current selected tab containing the datagrid which contains that row? Because there are 3 tabs containing 3 datagrids. I don’t want to get the output saying there are 3 datagridviews selected with whatever row was selecting. I want the one row on my screen.

Please ask me if my question isn’t clear enough.

  • 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-17T16:26:42+00:00Added an answer on June 17, 2026 at 4:26 pm

    I’m assuming that this question is about WinForms. Below there’s a schematic code logic sample for clicking a ToolStripMenuItem named Show selected row belonging to a MenuStrip on the form. Just adapt the method logic to your Modify and Delete buttons click events.

    public Form1()
    {
        InitializeComponent();
    
        dataGridView1.DataSource = new[] { new { Id = 1 }, new { Id = 10 } };
        dataGridView2.DataSource = new[] { new { Id = 2 }, new { Id = 20 } };
        dataGridView3.DataSource = new[] { new { Id = 3 }, new { Id = 30 } };
    }
    
    private void showSelectedRowToolStripMenuItem_Click(object sender, EventArgs e)
    {
        var dgv = tabControl1.SelectedTab.Controls.OfType<DataGridView>().FirstOrDefault();
        if(dgv != null)
        {
            if (dgv.SelectedRows.Count > 0)
            {
                // I'm using MessageBox to show the index of the row. 
                // You should add your Modify / Delete logic
                MessageBox.Show(dgv.SelectedRows[0].Index.ToString());
            }
        }
    }
    

    For the .NET Framework 2.0, you can find the selected tab’s first DataGridView control, if existing, like this:

    DataGridView dgv = null;
    for (int i = 0; i < tabControl1.SelectedTab.Controls.Count; i++)
    {
        if (tabControl1.SelectedTab.Controls[i].GetType() == typeof(DataGridView))
        {
            dgv = (DataGridView)tabControl1.SelectedTab.Controls[i];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WinForm project that contains a form called MainUI. You can see
I have a very simple Project form with a name field and a select
In my ASP.NET Web-form Project I have an Event which Export Data ( List<Profit>
I have a project to setup an anonymous feedback form to our website. I
I have a project with a main MDI form. There is a child MDI
I have a c# windows form project using watin. I would love to attach
in my project i have one registration form which is developed in C#.net.to this
I have a class project where I am using a VB.Net form to search
I have the following project. The main form has control in it. This control
I have inherited a project, that provides an order form to a customer. The

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.