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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:59:08+00:00 2026-05-27T02:59:08+00:00

I had to copy a datagridview to another, in order to iterate through it

  • 0

I had to copy a datagridview to another, in order to iterate through it within a backgroundworker thread, creating an excel export.

The copy was made to allow users to made some changes in the original datagridview, during the export.

So I created a new DataGridView (programatically), and put a copy of the original DataTable into the DataSource property of the new DataGridView.
However, I figured out that if I don’t add the datagridview in the Controls (list) property of any Form, the RowCount still equals to 0…

Can someone can explain this?

Note : The copy of the DataTable is just a new DataTable with copy() of Columns.

  • 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-27T02:59:09+00:00Added an answer on May 27, 2026 at 2:59 am

    This is quite simple. When you just created your DataGridView (or any other WinForms or Wpf control) it is created only in .Net. E.g. there is no system window created for it. And while control is in this state, it don’t apply any bindings for optimization purposes (why should visual control do anything, while it is invisible? :)). When you add your control to the visible form, control will have its system window created (i.e. its Handle property will be initialized) and it will start work as expected.
    If you want to make any visual control to work as intented, but not really show it, you simply need to read its Handle property. This will force control to create a system window and fully initialize.
    Also for WPF it is a bit harder, because you can get a handle only for Window control and in order to get it you have to use following code:

    public IntPtr GetWpfWindowHandle(Window w)
    {
       var interopHelper = new WindowInteropHelper(w);
       return interopHelper.Handle;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My company purchased Visual Studio Pro 2008 last year, which had a 'free' copy
I had a msdn registered copy of Expression Studio installed on my machine and
Had a page that was working fine. Only change I made was to add
Hello i had a simple copy file program in C but i cant explain
I'm creating a custom powershell 1.0 cmdlet that will allow me to feed exceptions
I had a discussion this morning with a colleague about static variable initialization order.
I had implemented copy to clipboard functionality. It is working fine with all version
I have a working copy of code on my desktop that had a repo
If I wanted to determine if a user had a genuine copy of windows,
I had to copy the data from oracle tables to files. I have a

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.