Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Usercontrol with maskedit

Posted on 2006-06-21
7
Medium Priority
?
397 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
[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
  • 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
Independent Software Vendors: 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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

660 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