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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:13:19+00:00 2026-05-23T02:13:19+00:00

Hello People im filling datagrid when on forms load event this way: private void

  • 0

Hello People im filling datagrid when on forms load event this way:

 private void Inventory_Load(object sender, EventArgs e)
    {

        AcidDBDataContext db = new AcidDBDataContext();

        BindingSource bs = new BindingSource();
        bs.DataSource = db.GetProducts.ToList();

        dgvInventory.DataSource = bs;
        ProductBindingNavigator.BindingSource = bs;

        ShowtoolStripButton2.Visible = false;

        foreach (DataGridViewColumn c in dgvInventory.Columns)
        {
            c.DefaultCellStyle.Font = new Font("Arial", 12.0F, GraphicsUnit.Pixel);
        }

    }

its working fine but there is one problem i needs few second and my form is freezing. How i can do while my datagrid is filling show loading animation and when grid will be filled hide animation

Im using C# winForms.
THanks a lot

  • 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-23T02:13:19+00:00Added an answer on May 23, 2026 at 2:13 am

    You could look into BackgroundWorkerThreads.

    http://www.albahari.com/threading/part3.aspx

    I used them quite a bit while retrieving data. I would display a waiting bar, call the DoWork event where data is retrieved into a dataset (for us, this usually took longer than attaching said data to the grid), then in the RunWorkerCompleted event I attached the data to the grid and hid the waiting bar. The app still froze for a few seconds, but not nearly as long.

    Here’s some sample code. Basically, lock fields that could cause RefreshInventory to be called again (but since you’re loading at startup maybe that doesn’t apply to you). Then retrieve the data in the thread and attach it when the thread is done.

    public void RefreshInventory()
    {
        // Lock any fields you want to lock during the update process
        // Display some kind of waiting or progress bar
        if (!bkgdWrkInventory.IsBusy)
            bkgdWrkInventory.RunWorkerAsync();
    }
    
    private void bkgdWrkInventory_DoWork(object sender, DoWorkEventArgs e)
    {
        var db = new AcidDBDataContext();
        e.Result = db.GetProducts.ToList();
    }
    
    private void bkgdWrkInventory_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
    {
        if (e.Error == null)  // Check for errors
        {
            dgvInventory.DataSource = (List<Product>)e.Result;
        }
        else
        {
            // Show the error to the user
        }
    
        // Hide the waiting indicator
        // Unlock the fields
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello can anybody solve this please I'm creating the object in the action class
Let's say I have this sample: page = <html><body><h1 class='foo'></h1><p class='foo'>hello people<a href='http://'>hello world</a></p></body></html>
Hello good people of stackoverflow, this is a conceptual question and could possibly belong
Hello kind computing people, Okay this is super broad, but I thought I'd give
import static com.example.hello.Tools.*; public class MAINCLASS{ public void run(){ runtools(); // this works }
Hello people I'm trying to figured this out, but I still can't do it.
Hello fellow Computer People! I could do this myself, but was just wondering if
Hello friendly computing people, This is a two part question. I'm writing two shell
Hello again Stackoverflow people! Assume I have these words: smartphones, smartphone I want to
Hello I am working with a simulator that uses rcS scripts to boot, this

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.