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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:41:16+00:00 2026-06-08T15:41:16+00:00

I have two datagrids in my application ( dataGridView1 and dataGridView2 ). I am

  • 0

I have two datagrids in my application (dataGridView1 and dataGridView2). I am moving selected items from dataGridView1 into dataGridView2. Here is how I am currently doing this:

DataTable dt = new DataTable("dt");
DataTable id = new DataTable("id");
try
{
    if (dataGridView1.Rows.Count > 0)
    {
        for (int i = 0; i < dataGridView1.Rows.Count - 0; i++)
        {
            if (dataGridView1.Rows[i].Cells[0].Value != null)
            {
                DataRow row;
                DataRow idRow;
                row = dt.NewRow();
                idRow = id.NewRow();
                idRow["id"] = dataGridView1.Rows[i].Cells[1].Value.ToString();
                row["id"] = dataGridView1.Rows[i].Cells[1].Value.ToString();
                row["Link Name"] = dataGridView1.Rows[i].Cells[2].Value.ToString();
                dt.Rows.Add(row);
                id.Rows.Add(idRow);
            }
        }
    dataGridView2.DataSource = dt;
}

However, I also need to be able to remove items from dataGridView2. Currently, the DataTable dt is bound to dataGridView2 and I cant clear it after the items are added because it also clears the dataGridView2.

Basicly, my question would be, is there a way to add the contents of a data table to a data grid without using datagrid.DataSource?

  • 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-08T15:41:18+00:00Added an answer on June 8, 2026 at 3:41 pm

    You can manually add each row using the dataGridView2.Rows.Add function. Also, I have typically used the dataGridView2.Row(n).Tag to hold the actual source of that row’s data.

    int n = dataGridView2.Rows.Add();
    DataGridViewRow newRow = dataGridView2.Rows[n]; 
    newRow.Cells[0].Value  = "ABC";
    newRow.Cells[1].Value  = 123;
    newRow.Tag = row;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF application with two DataGrids that share the same ItemsSource. When
I have two silverlight (2 or 3) datagrids (from the July 2009 Silverlight toolkit)
I have an AIR application with two DataGrids that I would like to export
I have two Datagrids. You can switch Items between it by Doubleclinking on one
Have two actionsheet buttons and one modalviewcontroller on mainviewcontroller in application. Now for two
I have two classes (MVC view model) which inherits from one abstract base class.
In my application I have a datagrid that populates with info from a SQLserver
I have two datagrids side by side bound to different data tables and each
I have an Application with two Tabs in WPF. One is Used to add
I have two datagrids with one column each. First: <DataGrid.Columns> <DataGridTextColumn x:Name=FilterTextCol01 IsReadOnly=False Width={Binding

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.