can datagrid be controlled from another form?

  • Thread starter Thread starter Adda
  • Start date Start date
A

Adda

I have a datagrid on one form but I add data to the
datasource from another form, using a different dataset
object (but same dataset.xsd) and different adapter than
the adapter for the datagrid form. Is there any syntax
for manipulating the datagrid from the other form? Here
is something I tried that did not reflect any updates in
the datagrid from the second form

Sub AddRec(...)...
Dim dr As datarow, frm As New datagridForm
dr = frm.gridDataset.Tables("tbl1").NewRow
dr(0) = txt0.Text
dr(1) = txt1.Text
frm.gridDataset.Tables("tbl1").Rows.Add(dr)
frm.gridAdapter.Update(frm.gridDataset, "tbl1")
End Sub

This adds a new record to the datasource but it does not
show up in the datagrid on the datagridForm. I had to add
a button to the datagridForm to clear the dataset and
refill it with the gridAdapter on the datagridForm. Then
the new record shows up. I tried clearing and refilling
from the second form but nothing showed up in the
datagrid. Is there a way to control the datagrid from the
second form?

TIA
Adda
 
Hi Adda,

When you do not use the designer (or only as a kind of tool) however create
your data handling in a seperated (shared) class, everyting becomes very
easy.

In the resource kit are a lot of short samples how to do that, one of them
in the dataacces section to look for is the sample about the typed dataset
(which you are using now) because in that is also an untyped dataset.

http://msdn.microsoft.com/vbasic/vbrkit/default.aspx

And if you have problems installing it

http://msdn.microsoft.com/vbasic/vbrkit/faq/#installvdir

I hope this helps a little bit?

Cor
 
Back
Top