Form Inheritence

G

Guest

I have a base form in VB.Net (Name and address). It has datasets.
I inherit this form and add add'l Info (ie: Phone Numbers)
I inherit from this form and add specific logic for the business need.
I don' t think I need to discuss the advantages of inheritance within this
forum, so here is the problem:

The form was originally designed in .Net 1.0 and upsized to .Net 1.1
The designer reconfigures all of the code such that sometimes (very
frustrating to debug), the redisigned code tries to reinitialize the dataset
which was inherited from the base form. This causes a runtime error since we
are trying to initialize a datarelation which has already been initialized.

Any Thoughts?
 
J

Jeffrey Tan[MSFT]

Hi Tom,

Based on my understanding, you migrate your .Net Framework1.0 code to .Net
1.1, then you meet some runtime error of initializing dataset.

First, is the dataset a typed dataset(generated by IDE?) or untyped? Also,
what does "reinitialize the dataset which was inherited from the base form"
mean? How does a dataset inherit from a form?
I think I still have some understanding issue about your problem, can you
provide me some more detailed information about your problem, then I can
understand it well and help you out. Thanks.

I suppose you use typed dataset in your application, then can you paste
some reproduce steps or sample code snippet to help us to reproduce this
issue? Thanks again.

=================================================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jeffrey Tan[MSFT]

Hi Tom,

Does my reply make sense to you? Is your problem resolved?

Please feel free to feedback. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
G

Guest

Hi Jeffrey:

Sorry I couldn't reply soon, but I appreciate your response. Here is a
little more information.

1. I am using a typed dataset
2. Build a windows form and a typed dataset
3. Put the dataset in the form
4. Create a new inherited windows form which inherits from the form in step 2.
5. Save

If you open/close the form and/or open/close Studio, I am having intermitent
problems where the designer is trying to initialize the dataset in the child
form. This causes an error because the dataset was already initialized upon
instantiation of the parent.

I'm dealing with a rather complicated form with user controls and external
references so it would be difficult to post up the actual problem. I'm
currently rebuilding the forms from scratch to see if it doesn't clear up. If
this rebuild still causes problems, I'll attempt to build a small demo.

If you can make heads or tails out of the above and have any suggestions,
they would be appreciated.

Thanks,

Tom
 
J

Jeffrey Tan[MSFT]

Hi Tom,

Sorry for letting you wait for so long.

In your parent form, do your initialize the typed dataset in parent form's
constructor? Because the inherited form will call the parent form's
constructor, so the initialization will occurs twice. Can you show me why
you want to inherit from the parent form? Maybe we can find a way to
workaround this.

Also, because this behavior only occurs at design-time, we may remove the
inialization code in parent form from constructor to Form_Load method, then
we may use Form.Site.DesignMode property to check if it is design-time and
disable this code snippet at design-time.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top