Solved

Usercontrol with maskedit

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

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
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 …
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

821 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