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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:34:08+00:00 2026-06-12T00:34:08+00:00

I am seting a datasource of a dataGridview to a table. First In Load

  • 0

I am seting a datasource of a dataGridview to a table.
First In Load Event

Datagridview.datasource=DTFromSQl

In some Random Event I do.

Dim Dt as datatable=DataGridview1.datasource

When I do DT.rows.clear() it also clears the rows in the Datagridview. I suppose its due to databinding. But how is the databind occuring? and how to remove it so that changes in DT occurs in it only.

Thanks


Ok I did it but, something doesnt feel right about it.

Dim DTSend As New DataTable

    For i As Integer = 0 To DataGridView1.ColumnCount - 1
        DTSend.Columns.Add(DataGridView1.Columns(i).Name)
    Next
  • 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-12T00:34:09+00:00Added an answer on June 12, 2026 at 12:34 am

    Use the following code. when you will clear the datatable it will not clear your datagridview

     Dim dtsend As DataTable
    
     dtsend = CType(DataGridView1.DataSource, DataTable).Copy()
    
     dtsend.Clear()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm adding a DataGridViewComboBoxColumn to a DataGridView during the form's Load event handler and
I have a DataGridView with a few DataGridViewComboBoxColumn's. The columns have their DataSource set
I have a datagridview which is initially bound to an empty datatable. Then the
I have a DataGridView bound to a list of business objects: Dim template As
I have a DataGridView that is filled by setting its DataSource to a DataBinding.
I want to make a C# DataGridView's DataSource be a HashTable where there are
I have problem related to datagridview in Winform. I have a list of table
I have a Many to Many mixed with some Master-Detail DataGrid setup. 4 DataGridView
I'm confused as to why setting the datasource of a datagridview control to null,
Basically I'm setting my datasource on my gridview to a datatable that I filled

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.