Solved

Usercontrol with maskedit

Posted on 2006-06-21
7
395 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
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

617 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