controls -inheritance

Posted on 2009-04-17
Last Modified: 2012-05-06
Hi everyone,

In a VB.NET 2005 Windows application.

I have a control MyCbo that Inherits System.Windows.Forms.ComboBox

I have been using this control across the application.

Now I have a procedure that I need to fire whenever the "Leave" event is triggered

The purpose is to add the "Not In list" functionality to the combobox across the application instead of going to every form /combobox and calling the function on the "Leave" event.

Is this possible?
What could be the code to call my NotInlist Function for the "Leave" event?


Question by:George
    LVL 48

    Accepted Solution

    You can create a new property and then on leave event you check if the item is in the list and set the property to true or false. something like:
    Public Class MyCbo
        Inherits ComboBox
        Private m_NotInlist As Boolean
        Public Property NotInlist() As Boolean
                Return m_NotInlist
            End Get
            Set(ByVal value As Boolean)
                m_NotInlist = value
            End Set
        End Property
        Private Sub MyCbo_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Leave
            ' You code to check if the item are in the list
            if ... Then
                Me.NotInlist = True
                Me.NotInlist = False
            End If
        End Sub
    End Class

    Open in new window


    Author Closing Comment

    Thank you jpaulino!

    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    Article by: Kraeven
    Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    This video discusses moving either the default database or any database to a new volume.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    754 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

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now