How can I suppress a form's native subroutine (show method) and replace it with several overloads (do I use shadow?)

Posted on 2009-12-17
Last Modified: 2012-05-08
I want to replace my form's native "show" method with several overloaded subroutines that I've built.  I want to make sure that the native 'show' routine can not be seen.  Will shadow do this?
Question by:David L. Hansen
    LVL 15

    Accepted Solution

    Yes you can

          Shadows Sub Show()
          End Sub

          Shadows Function ShowDialog() As DialogResult
             Return MyBase.ShowDialog
          End Function

    But if it is the main Window and you has selected it as initial Form in the application panel, Form.Show is called.
    LVL 15

    Expert Comment

    Also if your form is Form1 then
      Directcast(Form1,Form).Show  - bypass Shadow Function.
    LVL 15

    Author Comment

    by:David L. Hansen
    I'm curious about something: if I have one routine that overloades the native 'Show' sub I have to use the 'Overloads' keyword (the ide forces me to).  I guess that's because I'm not just overloading my own custom routine but a native .net routine.  Now, I would have assumed that in the case where I'm not only overloading the native routine but also shadowing it, that I'd have to use both keywords: 'Overloads' and 'Shadows' in the declaration (especially since I have several 'Show' subs that I'm inserting) .  I see however that the IDE doesn't force me to do that though; any idea why?
    LVL 15

    Expert Comment

    When a sub or Function is declared as overridable, then is a Virtual Function (Called by Reference).
    If you overrides the Function, the overrided method is called.
    You can also in this case call MyBase.OveridedFunction. It calls it on No Virtual mode.

    If you Shadows or overloads a function, yo can each Shadowed or not sadowed Functions
    In this case you have Form.Show and also Form1.Show functions.

    Dim f as Form = New Form1.
    F.Show - Calls Form.Show not Form1.Show
    LVL 15

    Author Closing Comment

    by:David L. Hansen
    Thank you very much.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
    Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    758 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

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now