Results 1 to 4 of 4

Thread: [Resolved]Possible to make Interval ReadOnly in Timer?

  1. #1

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Resolved [Resolved]Possible to make Interval ReadOnly in Timer?

    I have a class that is derived from the System.Windows.Forms.Timer class and I would like to make Interval ReadOnly.

    Is this possible?
    Last edited by Kasracer; Jan 2nd, 2006 at 08:07 AM.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  2. #2
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142

    Re: Possible to make Interval ReadOnly in Timer?

    if you inherit the timer ( as a custom class )
    declare Interval as a Shadows Property, like this ...
    VB Code:
    1. Public Class tmr
    2.     Inherits Timer
    3.  
    4.     Public Shadows ReadOnly Property Interval() As Integer
    5.         Get
    6.  
    7.         End Get
    8.     End Property
    9.  
    10. End Class
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Possible to make Interval ReadOnly in Timer?

    Because the Interval property is not declared Overridable, Shadowing is the only possibility. Just note though that while Shadowing is similar to Overriding, a Shadowed member is tied to the type, while an Overridden member is tied to the object. This means that if you have member A in a base class and you Override it in a derived class, casting a reference to a derived object as the base type will still only give you access to the derived implementation of member A. If you have member B in the same base class and you Shadow it in the same derived class, casting the same reference will actually give you access to the base implementation of member B. Try the following code to see what I mean:
    VB Code:
    1. Public Class Class1
    2.  
    3.     Public Overridable Sub MemberA()
    4.         MessageBox.Show("Base implementation of MemberA.")
    5.     End Sub
    6.  
    7.     Public Sub MemberB()
    8.         MessageBox.Show("Base implementation of MemberB.")
    9.     End Sub
    10.  
    11. End Class
    12.  
    13. Public Class Class2
    14.     Inherits Class1
    15.  
    16.     Public Overrides Sub MemberA()
    17.         MessageBox.Show("Derived implementation of MemberA.")
    18.     End Sub
    19.  
    20.     Public Shadows Sub MemberB()
    21.         MessageBox.Show("Derived implementation of MemberB.")
    22.     End Sub
    23.  
    24. End Class
    VB Code:
    1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         Dim myClass2 As New Class2
    3.  
    4.         myClass2.MemberA()
    5.         myClass2.MemberB()
    6.  
    7.         Dim myClass1 As Class1 = CType(myClass2, Class1)
    8.  
    9.         myClass1.MemberA()
    10.         myClass1.MemberB()
    11.     End Sub
    Also note that Overriding only affects the member with the same signature, i.e. a single overload if there are multiple, while Shadowing affects all members with that name. This doesn't mean that you should not use Shadows, but it is good to know what the implications are.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Possible to make Interval ReadOnly in Timer?

    Thank you guys very much
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width