By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,795 Members | 1,216 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,795 IT Pros & Developers. It's quick & easy.

Generic Control Validation

P: n/a
Ok, I've been looking through the .NET SDK docs and stuff.

I'm wondering if you can provide a control extender that does generic
validation or functionality just by dropping it on the form. For instance,
using the IExtenderProvider interface, you can specify properties, but there
is nothing documented about linking into a control's events.

For instance, in my application, there are specific formatting,
functionality and validation for all text boxes based on a couple of
property settings. Some of these text boxes have additional validation that
must be handled per control.

So, I want all my textboxes to automatically select all text when they get
tabbed into, on leaving, I want some generic special formatting applied
according to the property setting (if the data entered is in error,
automatically set the error provider to the error text (ie, invalid date,
invalid number, etc)). Some of this functionality (say allowing the
enter-key to move between fields).

Are we able to write an Extender control to do all of this in a generic
sense, intercept or handle certain control events, and still chain to the
normal control events? This would save a *ton* of coding, basically, just
drop the extender control on a form and set some fields and your entire
application has the same 'look-feel-functionality', and a common set of code
to adjust that without having to touch everything.

Reading a little more in the documentation, the ToolTop class seems to do
this, it pops up a tooltip if you hover over the control, but I can't see
any docs on how this is actually done.
Nov 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
> I'm wondering if you can provide a control extender that does generic
validation or functionality just by dropping it on the form. For instance, using the IExtenderProvider interface, you can specify properties, but there is nothing documented about linking into a control's events.


When the SetWhatever method is called, of your Extender class, use
AddHandler to hook into the controls events:

Public Sub SetMyProperty(ByVal ctlControl As Control, ByVal Value As String)
Nov 20 '05 #2

P: n/a
Thank you, I just happened to page into a similar example in the SDK. So
now, my next question is, does the extender interface just automatically add
"Set" and "Get" as a prefix to the property name I give in order to set and
retrieve property values? I know that this is just a sub, and I know that
it "appears" to be doing that, but just wanted a confirmation.

So, basically, adding two properties, EnterKeyNextField and SelectOnEntry
would need extender property/methods called SetEnterKeyNextField,
GetEnterKeyNextField and SetSelectOnEntry, GetSelectOnEntry. There is no
other code required to tell it that those are the two sets of property
handlers.

"Tom Spink" <th**********@ntlworld.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I'm wondering if you can provide a control extender that does generic
validation or functionality just by dropping it on the form. For instance,
using the IExtenderProvider interface, you can specify properties, but

there
is nothing documented about linking into a control's events.


When the SetWhatever method is called, of your Extender class, use
AddHandler to hook into the controls events:

Public Sub SetMyProperty(ByVal ctlControl As Control, ByVal Value As

String) .
.
.
AddHandler ctlControl.GotFocus, AddressOf MyGotFocusHandlerProc
.
.
.
End Sub

Public Sub MyGotFocusHandlerProc(ByVal Sender As Object, ByVal e As
System.EventArgs)
.
.
.
End Sub

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Maybe it's a game called 'Punish the User'"
"Richard Brown" <rb****@easylift.org> wrote in message
news:e$**************@tk2msftngp13.phx.gbl...
Ok, I've been looking through the .NET SDK docs and stuff.

I'm wondering if you can provide a control extender that does generic
validation or functionality just by dropping it on the form. For

instance,
using the IExtenderProvider interface, you can specify properties, but

there
is nothing documented about linking into a control's events.

For instance, in my application, there are specific formatting,
functionality and validation for all text boxes based on a couple of
property settings. Some of these text boxes have additional validation

that
must be handled per control.

So, I want all my textboxes to automatically select all text when they get tabbed into, on leaving, I want some generic special formatting applied
according to the property setting (if the data entered is in error,
automatically set the error provider to the error text (ie, invalid date, invalid number, etc)). Some of this functionality (say allowing the
enter-key to move between fields).

Are we able to write an Extender control to do all of this in a generic
sense, intercept or handle certain control events, and still chain to the normal control events? This would save a *ton* of coding, basically, just drop the extender control on a form and set some fields and your entire
application has the same 'look-feel-functionality', and a common set of

code
to adjust that without having to touch everything.

Reading a little more in the documentation, the ToolTop class seems to do this, it pops up a tooltip if you hover over the control, but I can't see any docs on how this is actually done.


Nov 20 '05 #3

P: n/a
There should be an attribute attached to the Get method, and also to your
class:

<WatchForWrapping>

<ProvideProperty("Whatever", GetType(Control)) > _
Public Class MyExtenderClass
Inherits Component
Implements IExtenderProvider

<ExtenderProvidedProperty()> _
Public Function GetWhatever(ByVal ctlControl As Control) As String
Return "Foo"
End Function

Public Sub SetWhatever(ByVal ctlControl As Control, ByVal strValue As
String)
' Bar
End Sub

Public Function CanExtend(ByVal extendee As Object) As Boolean
Implements System.ComponentModel.IExtenderProvider.CanExtend

If TypeOf extendee Is Control Then
Return True
Else
Return False
End If

End Function

End Class

</WatchForWrapping>

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Maybe it's a game called 'Punish the User'"
"Richard Brown" <rb****@easylift.org> wrote in message
news:O6*************@tk2msftngp13.phx.gbl...
Thank you, I just happened to page into a similar example in the SDK. So
now, my next question is, does the extender interface just automatically add "Set" and "Get" as a prefix to the property name I give in order to set and retrieve property values? I know that this is just a sub, and I know that
it "appears" to be doing that, but just wanted a confirmation.

So, basically, adding two properties, EnterKeyNextField and SelectOnEntry
would need extender property/methods called SetEnterKeyNextField,
GetEnterKeyNextField and SetSelectOnEntry, GetSelectOnEntry. There is no
other code required to tell it that those are the two sets of property
handlers.

"Tom Spink" <th**********@ntlworld.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I'm wondering if you can provide a control extender that does generic
validation or functionality just by dropping it on the form. For

instance,
using the IExtenderProvider interface, you can specify properties, but

there
is nothing documented about linking into a control's events.


When the SetWhatever method is called, of your Extender class, use
AddHandler to hook into the controls events:

Public Sub SetMyProperty(ByVal ctlControl As Control, ByVal Value As

String)
.
.
.
AddHandler ctlControl.GotFocus, AddressOf MyGotFocusHandlerProc
.
.
.
End Sub

Public Sub MyGotFocusHandlerProc(ByVal Sender As Object, ByVal e As
System.EventArgs)
.
.
.
End Sub

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Maybe it's a game called 'Punish the User'"
"Richard Brown" <rb****@easylift.org> wrote in message
news:e$**************@tk2msftngp13.phx.gbl...
Ok, I've been looking through the .NET SDK docs and stuff.

I'm wondering if you can provide a control extender that does generic
validation or functionality just by dropping it on the form. For

instance,
using the IExtenderProvider interface, you can specify properties, but

there
is nothing documented about linking into a control's events.

For instance, in my application, there are specific formatting,
functionality and validation for all text boxes based on a couple of
property settings. Some of these text boxes have additional validation
that
must be handled per control.

So, I want all my textboxes to automatically select all text when they get tabbed into, on leaving, I want some generic special formatting
applied according to the property setting (if the data entered is in error,
automatically set the error provider to the error text (ie, invalid date, invalid number, etc)). Some of this functionality (say allowing the
enter-key to move between fields).

Are we able to write an Extender control to do all of this in a generic sense, intercept or handle certain control events, and still chain to the normal control events? This would save a *ton* of coding, basically, just drop the extender control on a form and set some fields and your entire application has the same 'look-feel-functionality', and a common set
of code
to adjust that without having to touch everything.

Reading a little more in the documentation, the ToolTop class seems to

do this, it pops up a tooltip if you hover over the control, but I can't see any docs on how this is actually done.



Nov 20 '05 #4

P: n/a
Ok, going the wrong way now.... I'm more confused, sorry...

The documentation says that the <ExtenderProvidedProperty()> is for support
of the .NET framework and should not be used in my code. Also, I *still* do
not see a specific statement that says "SetWhatever" is used to set the
"Whatever" property. My question was, does the .NET Framework *imply* that
if you extend a property "Whatever", you must have a method or function of
"SetWhatever" for it to work correctly? Or is there something that you
specifiy to link a specific property name to a specific handler function?

"Tom Spink" <th**********@ntlworld.com> wrote in message
news:uk**************@TK2MSFTNGP11.phx.gbl...
There should be an attribute attached to the Get method, and also to your
class:

<WatchForWrapping>

<ProvideProperty("Whatever", GetType(Control)) > _
Public Class MyExtenderClass
Inherits Component
Implements IExtenderProvider

<ExtenderProvidedProperty()> _
Public Function GetWhatever(ByVal ctlControl As Control) As String
Return "Foo"
End Function

Public Sub SetWhatever(ByVal ctlControl As Control, ByVal strValue As
String)
' Bar
End Sub

Public Function CanExtend(ByVal extendee As Object) As Boolean
Implements System.ComponentModel.IExtenderProvider.CanExtend

If TypeOf extendee Is Control Then
Return True
Else
Return False
End If

End Function

End Class

</WatchForWrapping>

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Maybe it's a game called 'Punish the User'"
"Richard Brown" <rb****@easylift.org> wrote in message
news:O6*************@tk2msftngp13.phx.gbl...
Thank you, I just happened to page into a similar example in the SDK. So
now, my next question is, does the extender interface just automatically

add
"Set" and "Get" as a prefix to the property name I give in order to set

and
retrieve property values? I know that this is just a sub, and I know that it "appears" to be doing that, but just wanted a confirmation.

So, basically, adding two properties, EnterKeyNextField and SelectOnEntry would need extender property/methods called SetEnterKeyNextField,
GetEnterKeyNextField and SetSelectOnEntry, GetSelectOnEntry. There is no other code required to tell it that those are the two sets of property
handlers.

"Tom Spink" <th**********@ntlworld.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
> I'm wondering if you can provide a control extender that does generic > validation or functionality just by dropping it on the form. For
instance,
> using the IExtenderProvider interface, you can specify properties, but there
> is nothing documented about linking into a control's events.

When the SetWhatever method is called, of your Extender class, use
AddHandler to hook into the controls events:

Public Sub SetMyProperty(ByVal ctlControl As Control, ByVal Value As

String)
.
.
.
AddHandler ctlControl.GotFocus, AddressOf MyGotFocusHandlerProc
.
.
.
End Sub

Public Sub MyGotFocusHandlerProc(ByVal Sender As Object, ByVal e As
System.EventArgs)
.
.
.
End Sub

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Maybe it's a game called 'Punish the User'"
"Richard Brown" <rb****@easylift.org> wrote in message
news:e$**************@tk2msftngp13.phx.gbl...
> Ok, I've been looking through the .NET SDK docs and stuff.
>
> I'm wondering if you can provide a control extender that does generic > validation or functionality just by dropping it on the form. For
instance,
> using the IExtenderProvider interface, you can specify properties, but there
> is nothing documented about linking into a control's events.
>
> For instance, in my application, there are specific formatting,
> functionality and validation for all text boxes based on a couple of
> property settings. Some of these text boxes have additional validation that
> must be handled per control.
>
> So, I want all my textboxes to automatically select all text when
they get
> tabbed into, on leaving, I want some generic special formatting applied > according to the property setting (if the data entered is in error,
> automatically set the error provider to the error text (ie, invalid

date,
> invalid number, etc)). Some of this functionality (say allowing the
> enter-key to move between fields).
>
> Are we able to write an Extender control to do all of this in a generic > sense, intercept or handle certain control events, and still chain
to the
> normal control events? This would save a *ton* of coding,
basically, just
> drop the extender control on a form and set some fields and your entire > application has the same 'look-feel-functionality', and a common set of code
> to adjust that without having to touch everything.
>
> Reading a little more in the documentation, the ToolTop class seems

to do
> this, it pops up a tooltip if you hover over the control, but I
can't see
> any docs on how this is actually done.
>
>



Nov 20 '05 #5

P: n/a
> The documentation says that the <ExtenderProvidedProperty()> is for
support
of the .NET framework and should not be used in my code.
Okay, I can live with that. I just didn't see it in the docs when I was
messing with the Extender.
My question was, does the .NET Framework *imply* that
if you extend a property "Whatever", you must have a method or function of
"SetWhatever" for it to work correctly? Or is there something that you
specifiy to link a specific property name to a specific handler function?
Basically, Yes. That's it!! The SetWhatever and GetWhatever are
automatically attached to the property ('Whatever') you are extending. It's
just like a property statement block:

Property Foo() As Bar
Get
Return Moo
End Get
Set (Value As Bar)
Moo = Value
End Set
End Property

There are actually two methods created and compiled into your application,
when compiled... get_Foo and set_Foo.

Try a bit of proof (in the IDE):

Property Foo() As Integer
Get
Return 10
End Get
Set (Value As Bar)
' Do nothing
End Set
End Property

Function get_Foo() As Integer
Return 100
End Function

The IDE wavy line's the property and tells me off, because I have a get_Foo,
which is implicitally defined by the Property.

If you think of it like that, then it's not so bad. Your SetWhatever and
GetWhatever will automatically be attached to the property you are
extending.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Maybe it's a game called 'Punish the User'"
"Richard Brown" <rb****@easylift.org> wrote in message
news:OG**************@TK2MSFTNGP11.phx.gbl... Ok, going the wrong way now.... I'm more confused, sorry...

The documentation says that the <ExtenderProvidedProperty()> is for support of the .NET framework and should not be used in my code. Also, I *still* do not see a specific statement that says "SetWhatever" is used to set the
"Whatever" property. My question was, does the .NET Framework *imply* that if you extend a property "Whatever", you must have a method or function of
"SetWhatever" for it to work correctly? Or is there something that you
specifiy to link a specific property name to a specific handler function?

"Tom Spink" <th**********@ntlworld.com> wrote in message
news:uk**************@TK2MSFTNGP11.phx.gbl...
There should be an attribute attached to the Get method, and also to your
class:

<WatchForWrapping>

<ProvideProperty("Whatever", GetType(Control)) > _
Public Class MyExtenderClass
Inherits Component
Implements IExtenderProvider

<ExtenderProvidedProperty()> _
Public Function GetWhatever(ByVal ctlControl As Control) As String
Return "Foo"
End Function

Public Sub SetWhatever(ByVal ctlControl As Control, ByVal strValue As String)
' Bar
End Sub

Public Function CanExtend(ByVal extendee As Object) As Boolean
Implements System.ComponentModel.IExtenderProvider.CanExtend

If TypeOf extendee Is Control Then
Return True
Else
Return False
End If

End Function

End Class

</WatchForWrapping>

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Maybe it's a game called 'Punish the User'"
"Richard Brown" <rb****@easylift.org> wrote in message
news:O6*************@tk2msftngp13.phx.gbl...
Thank you, I just happened to page into a similar example in the SDK. So now, my next question is, does the extender interface just automatically add
"Set" and "Get" as a prefix to the property name I give in order to
set
and
retrieve property values? I know that this is just a sub, and I know that it "appears" to be doing that, but just wanted a confirmation.

So, basically, adding two properties, EnterKeyNextField and SelectOnEntry would need extender property/methods called SetEnterKeyNextField,
GetEnterKeyNextField and SetSelectOnEntry, GetSelectOnEntry. There is no other code required to tell it that those are the two sets of property
handlers.

"Tom Spink" <th**********@ntlworld.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
> > I'm wondering if you can provide a control extender that does generic > > validation or functionality just by dropping it on the form. For
> instance,
> > using the IExtenderProvider interface, you can specify properties, but > there
> > is nothing documented about linking into a control's events.
>
> When the SetWhatever method is called, of your Extender class, use
> AddHandler to hook into the controls events:
>
> Public Sub SetMyProperty(ByVal ctlControl As Control, ByVal Value As
String)
> .
> .
> .
> AddHandler ctlControl.GotFocus, AddressOf MyGotFocusHandlerProc
> .
> .
> .
> End Sub
>
> Public Sub MyGotFocusHandlerProc(ByVal Sender As Object, ByVal e As
> System.EventArgs)
> .
> .
> .
> End Sub
>
> --
> HTH,
> -- Tom Spink, Über Geek
>
> Please respond to the newsgroup,
> so all can benefit
>
> "Maybe it's a game called 'Punish the User'"
>
>
> "Richard Brown" <rb****@easylift.org> wrote in message
> news:e$**************@tk2msftngp13.phx.gbl...
> > Ok, I've been looking through the .NET SDK docs and stuff.
> >
> > I'm wondering if you can provide a control extender that does generic > > validation or functionality just by dropping it on the form. For
> instance,
> > using the IExtenderProvider interface, you can specify properties, but > there
> > is nothing documented about linking into a control's events.
> >
> > For instance, in my application, there are specific formatting,
> > functionality and validation for all text boxes based on a couple
of > > property settings. Some of these text boxes have additional validation
> that
> > must be handled per control.
> >
> > So, I want all my textboxes to automatically select all text when

they get
> > tabbed into, on leaving, I want some generic special formatting

applied
> > according to the property setting (if the data entered is in error, > > automatically set the error provider to the error text (ie, invalid date,
> > invalid number, etc)). Some of this functionality (say allowing the > > enter-key to move between fields).
> >
> > Are we able to write an Extender control to do all of this in a

generic
> > sense, intercept or handle certain control events, and still chain to the
> > normal control events? This would save a *ton* of coding, basically, just
> > drop the extender control on a form and set some fields and your

entire
> > application has the same 'look-feel-functionality', and a common
set of
> code
> > to adjust that without having to touch everything.
> >
> > Reading a little more in the documentation, the ToolTop class

seems to do
> > this, it pops up a tooltip if you hover over the control, but I can't see
> > any docs on how this is actually done.
> >
> >
>
>



Nov 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.