Update Counter not updating my DataGridView

shrug

I'm creating a Windows Form App in Visual Studio 2015. I have it communicating and sharing with our SQL Server perfectly for every function but one. I'd like to place a "live" counter on the form, that updates a value every 3(or something) seconds. The counter's job would be to keep track of inventory being shipped out of our warehouse (just need to worry about getting that info from our SQL Server, which already has the capabilities, nothing before that) and display that information. Doesn't have to be fancy, just accurate.

public void InitializeTimer()
    {
        var timer = new System.Timers.Timer();
        timer.Interval = 3;
        timer.Start();
        timer.Elapsed += keep_track_of_inventory_being_shipped;
    }

    private void keep_track_of_inventory_being_shipped(object sender, EventArgs e)
    {
        RefreshMyForm();
    }

    private void RefreshMyForm()
    {
        this.TableAdapter.Fill(this.DataSet.CMS);
    }
}

I had asked this question before (dynamic item counter from SQLServer 2014 in web form for Visual Studio 2015?) and I had thought I got it right but it was brought to my attention I was mistaken. So sadly I'm back... I have tried to modify the code with research on SO and other sources to get it working so this code looks different than the code in the URL I posted in the past. No dice.

Additional info: When the program first loads, "this.TableAdapter.Fill(this.DataSet.CMS);" loads the counter I want refreshed every few seconds (or minutes, whatever. I'll worry about that after the counter is working). It certainly does bring up the right count on program start, but I can't seem to get it to refresh at all. I am aware the last two methods may be overkill, but I decided to just leave it as is and ask. I started with the low interval just to check and see if it's updating. It's not :/ I don't get why there are no errors thrown up or why "this.TableAdapter.Fill(this.DataSet.CMS);" can update the count correctly from our database at start, but cannot be refreshed this way? If it's not asking too much, I'd prefer understanding this as well as suggestions to fix instead of just a fix.

The original solution posted by tchelidze was the one I previously went with, but I'm sure blame lies with me not implementing his suggestion correctly. I appreciate any help I can get, long time SO lurker here and I love the site/meta. Thanks all.

MethodMan

that's because you need to call the timer.Stop() when you get into RefreshMyForm then after the fill method has completed then call timer.Start() also the time is not accessible outside of this method public void InitializeTimer() you should drop a timer on the form and do it that way you should be calling your RefreshMyForm from the timer1_Tick Event

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Update Counter not updating my DataGridView

From Dev

Datagridview Updating

From Dev

My records are not updating (only 1st row of DataGridView)

From Dev

Why is my computer not updating via Windows Update?

From Dev

Update method for controller not updating my DB(Rails)

From Dev

Getting/Updating A Counter in DynamoDB

From Dev

Trying to create a character counter, but my button is not updating the while loop boolean to do so

From Dev

Updating datagridview via textboxes

From Dev

Updating A DataGridView Cell Incrementally

From Dev

Updating ComboBox Column in datagridview

From Dev

Pod Update is removing "Target Support Files" but not updating my project settings

From Dev

Cakephp 3 update query isn't updating my database

From Dev

SQL UPDATE, having problems updating my candidate table

From Dev

GIT Updating subtree: how can I update my subtree?

From Dev

Can update effect my code while updating project

From Dev

Updating web page caching when update my webpage

From Dev

My dataGridView isnt updating when i have edited a row of values in a seperate form

From Dev

Which is faster Counter()+=Counter or Counter.update(Counter)?

From Dev

Which is faster Counter()+=Counter or Counter.update(Counter)?

From Dev

Rails 4.1 counter cache not updating

From Dev

Updating counter in database using transaction

From Dev

Rails 4.1 counter cache not updating

From Dev

Predefined counter not updating in select statement

From Dev

Updating a counter in a python list of dictionaries

From Dev

Update counter on buttonpress

From Dev

Incrementing counter in update loop?

From Dev

Update badge counter in Swift

From Dev

How to update counter in jquery?

From Dev

SQL Change Counter ON UPDATE

Related Related

  1. 1

    Update Counter not updating my DataGridView

  2. 2

    Datagridview Updating

  3. 3

    My records are not updating (only 1st row of DataGridView)

  4. 4

    Why is my computer not updating via Windows Update?

  5. 5

    Update method for controller not updating my DB(Rails)

  6. 6

    Getting/Updating A Counter in DynamoDB

  7. 7

    Trying to create a character counter, but my button is not updating the while loop boolean to do so

  8. 8

    Updating datagridview via textboxes

  9. 9

    Updating A DataGridView Cell Incrementally

  10. 10

    Updating ComboBox Column in datagridview

  11. 11

    Pod Update is removing "Target Support Files" but not updating my project settings

  12. 12

    Cakephp 3 update query isn't updating my database

  13. 13

    SQL UPDATE, having problems updating my candidate table

  14. 14

    GIT Updating subtree: how can I update my subtree?

  15. 15

    Can update effect my code while updating project

  16. 16

    Updating web page caching when update my webpage

  17. 17

    My dataGridView isnt updating when i have edited a row of values in a seperate form

  18. 18

    Which is faster Counter()+=Counter or Counter.update(Counter)?

  19. 19

    Which is faster Counter()+=Counter or Counter.update(Counter)?

  20. 20

    Rails 4.1 counter cache not updating

  21. 21

    Updating counter in database using transaction

  22. 22

    Rails 4.1 counter cache not updating

  23. 23

    Predefined counter not updating in select statement

  24. 24

    Updating a counter in a python list of dictionaries

  25. 25

    Update counter on buttonpress

  26. 26

    Incrementing counter in update loop?

  27. 27

    Update badge counter in Swift

  28. 28

    How to update counter in jquery?

  29. 29

    SQL Change Counter ON UPDATE

HotTag

Archive