all groups > vb.net > january 2007 >
You're in the

vb.net

group:

amend a control by function or class


Re: amend a control by function or class lord.zoltar NO[at]SPAM gmail.com
1/31/2007 6:14:51 AM
vb.net:
On Jan 31, 8:38 am, "Benson Wong" <ben...@linktechsystem.com.hk>
[quoted text, click to view]

VB .NET allows for inheritance. The way I would do this is to create a
new textEdit control that inherits the original one:

Public Class MyCustomTextControl
inherits Windows.Forms.TextEdit '...or whatever control you want
to extend the functionality of...

Public Sub MyCustomeProcedure
Me.color = ...
Me.text = ....
End sub
End Class
Re: amend a control by function or class Phill W.
1/31/2007 3:52:28 PM
[quoted text, click to view]

Inherit a class of your own from TextBox and customise to your heart's
content.

When dealing with events in your class, extend the On* routines rather
than attaching event handlers, something like

Protected Overrides Sub OnLeave(ByVal e as EventArgs)
' Do the custom thing
Me.BackColor = Color.Green

' Get the TextBox to raise the Leave event
MyBase.OnLeave(e)

End Sub

HTH,
amend a control by function or class Benson Wong
1/31/2007 9:38:23 PM
I want to write a tailor-made function or class to amend textedit controls,
so that their properties are consistent or changed by some rules.
My idea is as follows:
TailorMadeRoutine(TextBox1)

sub TailorMadeRoutine(object textbox)
textbox.color=...
textbox.size=...
end

Is this idea works?
Benson
VB2005.

Re: amend a control by function or class lord.zoltar NO[at]SPAM gmail.com
2/1/2007 6:45:06 AM
[quoted text, click to view]


It should appear on the toolbox after you compile the files. If you
add any new properties to the inherited TextBox, you should see them
in the Properties panel in the design-view When you are adding your
new control to other controls or forms (Except for private or
writeonly properties, I think).
Re: amend a control by function or class Benson
2/1/2007 8:46:21 AM
Thanks.
Further Question:
Can I do the inheritance as follows?
1. Inherit TextBox
2. Create a new property ID
3. code the SETID procedure like this:
if ID="CUSTOMER" then
get database content
if something then .backcolor=color.green
if ...
end if
4. Will this new control appear on the toolsbox, so that I can drag it on
the form?

Thanks.
Benson.

"Phill W." <p-.-a-.-w-a-r-d@o-p-e-n-.-a-c-.-u-k>
???????:epqdvs$ekf$1@south.jnrs.ja.net...
[quoted text, click to view]

Re: amend a control by function or class Branco Medeiros
2/1/2007 10:18:06 AM
[quoted text, click to view]
<snip>

Actually, the control will appear in the tool box after you perform a
build (no need of a full compile).

HTH.
Regards,

Branco.
AddThis Social Bookmark Button