B
BobRoyAce
I am developing an application in VS2005, using VB.NET.
Suppose that I have a class, called Widget, which contains, among
other things, a List(Of WidgetDetail), where WidgetDetail is another
class.
Now, let's say that I have a Widget form, called WidgetForm, and that
it is used to enter Widgets. This form currently has a private module-
level variable, called m_oCurrentWidget which is an instance of
Widget. On WidgetForm, there is a button to add a new WidgetDetail to
be associated with the Widget being worked on currently on
WidgetForm.
When the user clicks on this button, another form, called
WidgetDetailForm, is shown that is used to enter information for a
WidgetDetail. The WidgetDetailForm form currently has a private module-
level variable, called m_oCurrentWidgetDetail, which is an instance of
WidgetDetail.
Well, what I want to do when the user clicks on the button, on the
WidgetDetailForm form, to confirm addition of the WidgetDetail, is to
add the WidgetDetail object defined on WidgetDetailForm, to
m_oCurrentWidget's WidgetDetailList (e.g.
m_oCurrentWidget.WidgetDetailList.Add(m_oCurrentWidgetDetail)). Given
that m_oCurrentWidget and m_oCurrentWidgetDetail are on two different
forms, what is the best way to implement something like this?
The more general question is, what's the best way to pass back an
Object from a form on which it is created?
Suppose that I have a class, called Widget, which contains, among
other things, a List(Of WidgetDetail), where WidgetDetail is another
class.
Now, let's say that I have a Widget form, called WidgetForm, and that
it is used to enter Widgets. This form currently has a private module-
level variable, called m_oCurrentWidget which is an instance of
Widget. On WidgetForm, there is a button to add a new WidgetDetail to
be associated with the Widget being worked on currently on
WidgetForm.
When the user clicks on this button, another form, called
WidgetDetailForm, is shown that is used to enter information for a
WidgetDetail. The WidgetDetailForm form currently has a private module-
level variable, called m_oCurrentWidgetDetail, which is an instance of
WidgetDetail.
Well, what I want to do when the user clicks on the button, on the
WidgetDetailForm form, to confirm addition of the WidgetDetail, is to
add the WidgetDetail object defined on WidgetDetailForm, to
m_oCurrentWidget's WidgetDetailList (e.g.
m_oCurrentWidget.WidgetDetailList.Add(m_oCurrentWidgetDetail)). Given
that m_oCurrentWidget and m_oCurrentWidgetDetail are on two different
forms, what is the best way to implement something like this?
The more general question is, what's the best way to pass back an
Object from a form on which it is created?