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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:28:23+00:00 2026-05-28T06:28:23+00:00

I am using vb.net. I have a datagridview to show data. Since the datagridview

  • 0

I am using vb.net. I have a datagridview to show data. Since the datagridview needs a filter function, I have an underlying data table of datagridview and filter the view of data table:

     PassFilter(m_table,"Price>0")
    Private Sub PassFilter(ByRef dataTable As DataTable, ByVal strFilter As String)     Try
        Dim dataview As New DataView(dataTable)
        dataview.RowFilter = strFilter
        'DGVTable is my datagridview
        DGVTable.DataSource = dataview
End Sub

This works well. But I have troubles in the following code:

      Private Sub UpdateTable()
      Dim row as dataRow=m_table.NewRow
      row("column1")=GetText()
      m_table.Rows.Add(row)
      End Sub

Note that GetText() seems be run on a different thread which returns value after the above codes for the first time.(I am not clear why this happens, but it seems that the second time to call GetText, it can get the value directly) This means that the column1 in m_table is actually empty after the above code for the first time, so datagridview is also empty since its datasource is m_table. I have no choice but to call the above sub again to update datagridview. This is inefficient.

The problem is I want to keep filter simple, then the underlying table seems necessary. But the table does not have invalidate as controls. So table cannot update values. I must call my sub again to update the table.

How can I keep filter simple as well as use datagridview.invalidate to update values so that my sub does not need to be called again?
Any help is apprecaited.

  • 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-28T06:28:24+00:00Added an answer on May 28, 2026 at 6:28 am

    You should not create a new view each time you want to filter your DataGrid with a different
    string, but rather just update the filter of the current default view.
    In the same idea of separating concerns, just assign once the default view of your DataTable to
    your DataGridView.
    To give an idea that would lead to a code like this :

    ' SetFilter : Set the current filter of MyDataTable to strFilter
    Private Sub SetFilter(ByVal MyDataTable As DataTable, ByVal strFilter As String)
        Dim DefaultViewOfMyDataTable As DataView = MyDataTable.DefaultView
        DefaultViewOfMyDataTable.RowFilter = strFilter
    End Sub
    
    ' And Somewhere else in the code / or in the xaml
    ' you put this sub that you should in the new or the loaded() sub of your window.
    
    ' InitDataGridView : Assign MyDataTable to MyDGV DataGridView
    Private Sub InitDataGridView(MyDGV As DataGridView, MyDataTable As DataTable)
        MyDGV.DataSource = MyDataTable.DefaultView
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using vb.net 2010. I have a datagridview whose data source is a
I have created a Data Access Layer using .NET. Everywhere that I update a
I am using Datagridview in asp.net. I have used custom buttons of up and
I have a very simple table in access. The data is stored from VB.NET
I do not have any idea on how to sort data using datagridview in
I'm new to using the C#/.NET programming Language and I have created a DataGridView
sending mail along with embedded image using asp.net I have already used following but
Using the .net framework you have the option to create temporary files with Path.GetTempFileName();
Using .NET 1.1, I have a DataGrid that contains three columns for each row.
I'm using .NET 3.5 and I have a class, A, marked as internal sealed

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.