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.

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.

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

I've question you need to update the result form every change user makes or every some time period?
I see you shouldn't overload the Show method rather make another one has two parameters dataset, string
gridview.datasource = dataset
gridview.DataBind()
And call this method from main form once user changes the criteria.

It would be fine if the form refreshes whenever the user adds new record to the table.

One more point I left out is, apart from the dataset columns, I have added two columns to the datagrid in the form load. One is an Image column and the other is converting the existing text column in the datagridview to a combo column.

This article has been dead for over six months. Start a new discussion instead.