Results 1 to 2 of 2

Thread: Autorefresh Windows Form

  1. #1
    shers is offline VB.NET Forum Enthusiast
    .NET Framework
    .NET 2.0 (VS 2005)
    Join Date
    Aug 2007
    Posts
    80
    Reputation
    74

    Autorefresh Windows Form

    Hi,

    I am working on VB.Net. I have a sub form with a datagridview, that is being loaded with the criteria taken from another form. Hence this form is called with parameters. Here is the code that calls the sub form.

    Code:
                        Dim frmHis As New frmHist(ds, rb)
    
                        frmHis.Show()
    where ds is the dataset to fill the datagridview and rb is the string from a radio button on this form.

    Here is the code in the sub form.

    Code:
    Public Sub New(ByVal datset As DataSet, Optional ByVal Head As String = "")
            ' This call is required by the Windows Form Designer.
            gdatset = datset
            InitializeComponent()
            grdHist.DataSource = datset.Tables(0)
            ' Add any initialization after the InitializeComponent() call.
            Label1.Text = Head
        End Sub
    Now, I need to refresh this sub form every -- minutes, depending on how the user wants it to be. For this I have given a NumericUpDown control to select the mins. All this works fine. But how do I refresh the dataset and the datagridview?

    Thanks

  2. #2
    Tom
    Tom is offline VB.NET Forum Idol
    .NET Framework
    .NET 3.5 (VS 2008)
    Join Date
    Aug 2005
    Posts
    746
    Reputation
    374
    The DataGridView does not need to be refreshed, when the contents of the dataset/datatable change; the changes will be seen in the DGV.

    To refresh your Dataset depends on what methods you used to fill it but essentially you will want to assign a dataadapter/tableadapter to control your Select/Fill, Insert/New, Delete & Update commands and run the dataadapter.update method which will cordinate all changes with the database

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Harvest time tracking