Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Usercontrol with maskedit

Posted on 2006-06-21
7
Medium Priority
?
400 Views
Last Modified: 2008-02-01
I've made an usercontrol on the basis of maskedEditBox.
Is there a way to pass all the functionality of the maskedEdit from the "inside" maskedEditbox to the "outside" of the usercontrol
without having to program all the functions and properties
0
Comment
Question by:dgb
  • 3
  • 2
  • 2
7 Comments
 
LVL 34

Expert Comment

by:Sancler
ID: 16952284
I don't think so.  To allow that would render encapsulation meaningless.

What you might be able to do - although I do not know if this would meet your needs - is, rather than making a usercontrol based on the masked edit box, make your own class which inherits from the masked edit box.  Then all the functions and properties of the base class would also be exposed in the inherited class.

Roger
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16953596
I agree with Roger.  Usually you wrap a different class to simplify the access methods, such as wrapping Windows API calls.  If you are going to encapsulate a MaskedEdit box, then you are looking to limit access to all the functionality.

Bob
0
 

Author Comment

by:dgb
ID: 16960835
Roger :
Can you explain it a bit more, maybe with a very small example


For now I've made an readonly property OrgObject wich passes the orginal maskedEditBox to the outside.
a bit of a workaround but it works.

Thanks
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!

 
LVL 34

Accepted Solution

by:
Sancler earned 2000 total points
ID: 16961964
Here's a very simple example

Public Class MyMaskedEdit

    Inherits Windows.Forms.MaskedTextBox

    Public Sub setEuropeanDate()
        Me.Mask = "00 LLL 0000"
        Me.BackColor = Color.AliceBlue
        Me.ValidatingType = GetType(Date)
    End Sub

    Public Sub setUSDate()
        Me.Mask = "LLL 00 0000"
        Me.BackColor = Color.Bisque
        Me.ValidatingType = GetType(Date)
    End Sub

    Public Sub clearMask()
        Me.Mask = ""
        Me.BackColor = Color.White
    End Sub


End Class

An instance of MyMaskedEdit would expose all its standard properties and methods and, in addition, the methods shown above.  The first allows "one-call" setting of a mask that allows '01 Jan 2006' and changes the backcolor.  The second changes it to a mask that allows 'Jan 01 2006' with a different backcolor.  The third puts it into a 'standard' setting but with no mask.  It's so simple it's fatuous, but it illustrates what I meant.

Roger
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16962086
Roger,

It sounds like we are assuming 2005 and the MaskedTextBox, and it might be 2003 with the COM MaskEditBox control.

Bob
0
 
LVL 34

Expert Comment

by:Sancler
ID: 16963106
Bob

True

Public Class MyMaskedEdit

    Inherits AxMSMask.AxMaskEdBox

    Public Sub setEuropeanDate()
        Me.Mask = "99 ??? 9999"
        Me.BackColor = Color.AliceBlue
        Me.Focus()
    End Sub

    Public Sub setUSDate()
        Me.Mask = "??? 99 9999"
        Me.BackColor = Color.Bisque
        Me.Focus()
    End Sub

    Public Sub clearMask()
        Me.Mask = ""
        Me.BackColor = Color.White
        Me.Focus()
    End Sub

End Class

Even more fatuous, but still illustrative ;-)

Roger
0
 

Author Comment

by:dgb
ID: 16966906
It's 2005 so the first example is oke.

Gone check it out, meanwhile i will reward the points.

Thanks.

Dirk
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

885 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