Solved

Usercontrol with maskedit

Posted on 2006-06-21
7
390 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
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.

 
LVL 34

Accepted Solution

by:
Sancler earned 500 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

746 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

18 Experts available now in Live!

Get 1:1 Help Now