referencing a object in another form

  • Thread starter Thread starter Stan
  • Start date Start date
S

Stan

I have a dataset in one form that I instanciate there. I
would like to access that dataset from another form.
dim ds as new myds (myds is a dataset on the first form
and is generated from a dataAdapter on that form; it is
strongly typed).
I fill ds and then open another form. How can I reference
ds and access the data in it.
Thanks,
Stan
 
Hi,

You need to pass a reference to the dataset when you open the new
form.

Ken
 
* "Stan said:
I have a dataset in one form that I instanciate there. I
would like to access that dataset from another form.
dim ds as new myds (myds is a dataset on the first form
and is generated from a dataAdapter on that form; it is
strongly typed).
I fill ds and then open another form. How can I reference
ds and access the data in it.

The code below shows you how to do that with a textbox control. You can
adapt it for your needs easily.

In the 2nd form:

\\\
Private m_t As TextBox

Public Sub New(ByVal ResultTextBox As TextBox)
MyBase.New()
m_t = ResultTextBox
InitializeComponent()
End Sub

' You can access the control with m_t.
///


Main form:

\\\
Dim f As New Form1(Me.TextBox1)
f.Show()
///
 
Back
Top