Autorefresh Windows Form

shers

Well-known member
Joined
Aug 12, 2007
Messages
86
Programming Experience
1-3
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.

VB.NET:
                    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.

VB.NET:
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
 
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
 
Back
Top