?
Solved

Inherittance Question

Posted on 2005-03-11
7
Medium Priority
?
223 Views
Last Modified: 2010-04-23
Hello I have base from. On this form I have a protected property FormType. Now I have derived forms which inherit from this baseform. What I want to to do is set the base form property to a particular form type when a derived form is opnened and thus positioning and making certain controls invisible. I have tried to use the following code in the activated event of the derived form :

mybase.formtype = 1

however I cant seem to set the property of the base form in this event.

Can anybody help

0
Comment
Question by:anwarmir
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
7 Comments
 
LVL 12

Expert Comment

by:S-Twilley
ID: 13514971
Public Class SimpleForm
    Inherits System.Windows.Forms.Form   'taking a guess on this line :P

    private iFType As Integer

    Public Property FormType() As Integer
        Get
            Return iFType
        End Get
        Set(ByVal Value As Integer)
            iFType = Value
        End Set
    End Property

   '... rest of form code
End Class

=================

Public Class ExtendedForm
    Inherits SimpleForm

    Protected Overrides Sub OnActivated(ByVal e As System.EventArgs)
        MyBase.FormType = 1 'or whatever
    End Sub
End Class

===================

I've not tested this, but I think that's how it should all go... is that the same as you have?
0
 

Author Comment

by:anwarmir
ID: 13515206
No sorry this still does not work. In the load event of the the base form I have code to format the form depending upon which form has been opnened. Using the formtype property. However this gets executed before i can set the formtype of the base form in the derived forms.  

I followed your steps
Made the base class activivated event overridable
 Protected Overridable Sub PrintRange_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated
  End Sub

In the derived class I used the foolwoing code in the activated event

Protected Overrides Sub Printrange_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated
        MyBase.FormType = PrintRange.PrintFormType.ReprintPaymentReceipts
    End Sub

I also had to change the sub name to PrintRange  as I was getting an error. However this still does not execute until after the load event of the base form.
 

0
 
LVL 12

Expert Comment

by:S-Twilley
ID: 13515262
How about having a method to format the form in the base form ... which takes as an argument the form type.

Then in the load event of the derived form... call

MyBase.FormatIt(FormTypeValue)

I think that's kind of what you are after... I'm trying to do too many things at once at the mo so im sorry if that was a lil vague
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:anwarmir
ID: 13515691
OK I will try that...But it would be good to know if It is possible to change the tha base form property from a derived form so that it can be manipulated in the load event of the base class. Apologies not neccessary really appreciate your help
0
 
LVL 12

Expert Comment

by:S-Twilley
ID: 13515776
well you can try this (I think its nearer to what you were asking) ....

Public Class SimpleForm
    Inherits System.Windows.Forms.Form

    Private iFType As Integer

#Region " Windows Form Designer generated code "

    Public Sub New(ByVal FormType As Object)
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

        ' DO FORMATTING HERE DEPENDING ON FORM TYPE

        If FormType.ToString = "TEST" Then
            MsgBox("Wahoo")
        End If
    End Sub

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub
   ' THE REST OF FORM GENERATED CODE
    ' ....
     ' i left it out to save space
End Class

Public Class ExtendedForm
    Inherits SimpleForm



    Public Sub New()
        MyBase.New("TEST")
    End Sub
End Class
0
 
LVL 12

Expert Comment

by:S-Twilley
ID: 13515784
Then on a different extended form you might have :

Public Class AnotherExtendedForm
    Inherits SimpleForm

    Public Sub New()
        MyBase.New("SECONDTYPE")

    End Sub
End Class
0
 
LVL 12

Accepted Solution

by:
S-Twilley earned 2000 total points
ID: 13516120
Ok, hope either that workaround i posted, or the solution above works... just so you know, I'm going to be out of service for a few hours (need some sleep), so I won't be able to answer anything for a bit :P
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question