Groups | Blog | Home
all groups > vb.net controls > april 2005 >

vb.net controls : Shadows???


Fia
4/10/2005 12:00:00 AM
Hi

Below is a code for a combobox which acts like the comboboxes in Access. But
now when I'm using the combobxes event KeyUp to get this action, I don't
wan't programmers who uses this comboboxes to be able to use the event KeyUp
for their own code. Should I use shadows or is there a better way? I'm not
sure what Shadows really does. I would prefere that when a programmer uses
this combobox and looking at the comboboxes events in the event list, the
KeyUp wouldn't be in the event list. Is that possible to achieve.

Public Class IntelliCmb
Inherits System.Windows.Forms.ComboBox

Public Shadows Event KeyUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs)

Private Sub IntelliCombo_KeyUp(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp
Dim index As Integer
Dim actual As String
Dim found As String
' Do nothing for certain keys such as navigation keys
If ((e.KeyCode = Keys.Back) Or _
(e.KeyCode = Keys.Left) Or _
(e.KeyCode = Keys.Right) Or _
(e.KeyCode = Keys.Up) Or _
(e.KeyCode = Keys.Delete) Or _
(e.KeyCode = Keys.Down) Or _
(e.KeyCode = Keys.PageUp) Or _
(e.KeyCode = Keys.PageDown) Or _
(e.KeyCode = Keys.Home) Or _
(e.KeyCode = Keys.ShiftKey) Or _
(e.KeyCode = Keys.End)) Then
Return
End If

' Store the actual text that has been typed
actual = Text
' Find the first match for the typed value
index = FindString(actual)
' Get the text of the first match
If (index > -1) Then
found = Items(index).ToString()
' Select this item from the list
SelectedIndex = index
' Select the portion of the text that was automatically
' added so further typing will replace it
SelectionStart = actual.Length
SelectionLength = found.Length
End If
End Sub
End Class

Thank's
Fia

Scott M.
4/10/2005 9:20:47 PM
Shadows wouldn't help you protect your code from someone else shadowing it.
What you are looking for is a "sealed class", which is one that others can't
inherit from (and therefore make shadowed modifications to).

Simply declare your class like this:

Public NotInheritable Class IntelliCmb

and then others will be able to instantiate your class (with your code) but
they wouldn't be able to modify your code.


[quoted text, click to view]

NetRacer
4/11/2005 12:00:00 AM
if you declare it as "private shadows" it should not appear in the event
list of an instance.
is it what you want?

bye
netracer


"Fia" <fiaolle@telia.com> schrieb im Newsbeitrag
news:eFdQj4dPFHA.1884@TK2MSFTNGP15.phx.gbl...
[quoted text, click to view]

Scott M.
4/11/2005 10:50:26 AM
Reading you post again, I think I misunderstood your question. Mark your
class as I previously indicated (NotInheritable) and also mark the KeyUp
method as Private Shadows.


[quoted text, click to view]

Fia
4/12/2005 12:00:00 AM
Hi
Thank's for your answer, but I can still choose the KeyUp event from the
drop-down list Method Name in the Code Window. If the users of the
IntelliCmb control chooses the KeyUp event, they can't use the event, their
code never happens. But I don't want the KeyUp event to be visible in the
drop-down list, otherwise the users of the control can think that they can
use the event.
Maybe this can't be done, but if it can and you know how, please tell me.

Fia

"Scott M." <s-mar@nospam.nospam> skrev i meddelandet
news:OGrBhYqPFHA.580@TK2MSFTNGP15.phx.gbl...
[quoted text, click to view]

AddThis Social Bookmark Button