INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

HANDLE


PASSWORD
Remember Me
Forgot Password?

Come Join Us!

  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • Turn Off Ad Banners
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

E-mail*
Handle

Password
Verify P'word
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Member Feedback

"...this web site is a 'Godsend' for me. If I have a programming problem that I'm unable to solve, I'll get a sensible reply in no time. It's really great!..."

Geography

Where in the world do Tek-Tips members come from?

Visual Basic(Microsoft) -VB.NET 2002-2008 FAQ

How-to

How to add a NumericUpDown Control to a StatusStrip VB 2008
Posted: 11 Mar 09 (Edited 16 Mar 09)

The Status Strip is very nice to have on a form, but doesn't contain all of the controls you might need.  So here is an example of how to add a NumericUpDown control.  So a status strip can "see" your control automatically you will need to create a separate .dll for it.

CODE

Imports System.Windows.Forms
Imports System.Windows.Forms.Design

<System.ComponentModel.DesignerCategory("code")> _
<ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.StatusStrip)> _
Public Class ToolStripStatusNumericUpDown
    Inherits Windows.Forms.ToolStripControlHost

    Public Sub New()
        MyBase.New(New Windows.Forms.NumericUpDown)
    End Sub

    <System.ComponentModel.Browsable(False)> _
    Public ReadOnly Property NumericUpDownControl() As Windows.Forms.NumericUpDown
        Get
            Return CType(Control, Windows.Forms.NumericUpDown)
        End Get
    End Property

    Public Property value() As Integer
        Get
            Return NumericUpDownControl.Value
        End Get
        Set(ByVal value As Integer)
            NumericUpDownControl.Value = value
        End Set
    End Property

    Protected Overrides Sub OnSubscribeControlEvents(ByVal control As System.Windows.Forms.Control)
        MyBase.OnSubscribeControlEvents(control)

        Dim valueNumericUpDownControl As NumericUpDown = CType(control, NumericUpDown)
        AddHandler valueNumericUpDownControl.ValueChanged, AddressOf NumericUpDownControl_ValueChanged
    End Sub

    Protected Overrides Sub OnUnsubscribeControlEvents(ByVal control As System.Windows.Forms.Control)
        MyBase.OnUnsubscribeControlEvents(control)

        Dim valueNumericUpDownControl As NumericUpDown = CType(control, NumericUpDown)
        RemoveHandler valueNumericUpDownControl.ValueChanged, AddressOf NumericUpDownControl_ValueChanged
    End Sub

    Public Event ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs)
    Private Sub NumericUpDownControl_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        RaiseEvent ValueChanged(sender, e)
    End Sub
End Class

You should be able to add other controls in the same manner.

Back to Visual Basic(Microsoft) -VB.NET 2002-2008 FAQ Index
Back to Visual Basic(Microsoft) -VB.NET 2002-2008 Forum
My FAQ Archive
Email This FAQ To A Friend

My Archive