Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VB.Net inheritance : where's the controlsource?
Message
 
To
All
General information
Forum:
ASP.NET
Category:
Other
Title:
VB.Net inheritance : where's the controlsource?
Environment versions
Environment:
VB 8.0
OS:
Vista
Network:
Windows NT
Database:
Jet/Access Engine
Application:
Desktop
Miscellaneous
Thread ID:
01487042
Message ID:
01487042
Views:
120
My base textbox inherits maskedtextbox.

In VFP it used to be known as the "controlsource". With some gymnastics, you could get the type of field the controlsource was and you could apply a "mask" based on that type. At the risk of showing age ... and the fact that I forgot where I picked this up... here's my maskit routine.
local cConstrolSource, nAt, cAlias, a[1], n

*--	MG(eds) 10/07/98 - 11:18 - Now only default alligned numerics are left justified.

if  !this.lMaskit
	return
endif
cControlSource= alltrim(this.ControlSource)
*-- No controlSource, No Mask
if empty(cControlSource)    
    return
endif
*-- ControlSources are explicit
nAt= at('.',cControlSource)
if nAT= 0
	cAlias= alias()
else
	cAlias= left(cControlSource,nAT-1)
	if upper(cAlias)= "THISFORM"
		return
	endif
	if upper(cAlias)= "THIS"
		return
	endif
	*-- can't be
	if !used(cAlias)
	    wait this.Name+' has a controlSource on a closed table' window
	    return
	endif
endif
*-- find the Control Source's info form the database (ask oDb?)
select (cAlias)
cField= substr(cControlSource,nAt+1)
set fields to (cField)
n= afields(a,cAlias)
set fields to
set fields off
*-- can't be
if n= 0
    error this.Name+' xMask failure'
endif
*--
if empty(this.InputMask)
	do case
	case a[2]= 'N'
		*--	MG(eds) 10/07/98 - 11:20 
		if this.alignment= 3
			this.alignment= 0	&& left justify
	    endif
	    if a[4]=0
	        this.InputMask= repl('9',a[3])
	        this.format= 'IKZ'
	    else
	        this.InputMask= repl('9',a[3]-a[4])+'.'+repl('9',a[4])
	        this.format= 'IKZ'
	    endif
	case a[2]= 'C'
	    this.InputMask= repl('!',a[3])
	    this.format= 'KZ'
	case a[2]= "D"
		this.Inputmask= "99/99/99"
		this.format= "KD"
	endcase
endif
In vb.net at this stage I have to pass a Datacolumncollection. The problem with this is that I must call the maskit routine at the form level (that parses through the controls) from the load event of the instance, rather than from the form base because the bound table is named by the generator.

For example :
  Me.MasKit(Me.FeestdagenDataset.Feestdagen.Columns)

In VB?.Net my (unfinished) routine is :
Friend Sub MaskIt(ByVal cols As DataColumnCollection) Implements IControlMaskit.MaskIt
        If Me.Mask <> "" Then
            Exit Sub
        End If
        Dim o As DataColumn = cols(Me.DataBindings.Item(0).BindingMemberInfo.BindingField)
        Dim cT As String = o.DataType.ToString
        If cT = "System.String" Then
            Me.Mask = ">" & New String("A", o.MaxLength)
            Exit Sub
        End If
        If cT = "System.DateTime" Then
            Me.Mask = ">##/AAA/##"
            Exit Sub
        End If
        MsgBox(Me.Name & " cannot be masked yet (" & cT & ")")
    End Sub
So... is there a way to determine the "bound" table from a textbox that is bound to a field?

Maybe I should change my signature to the Chinese saying, "I wanted to write something short, but I only had time for this"

Thanks

Marc

If things have the tendency to go your way, do not worry. It won't last. Jules Renard.
Reply
Map
View

Click here to load this message in the networking platform