INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

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

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

How-to

How to add a NumericUpDown Control to a StatusStrip VB 2008 by Sorwen
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 FAQ Index
Back to Visual Basic (Microsoft) VB.NET Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close