Reputation: 11
I created a Windows Form in Visual Basic which contains a MenuStrip. I need to add a label in that MenuStrip which should display the current user's login details and domain info but for some reason I can't drag and drop a label in that MenuStrip. Any help would be highly appreciated!
I went through VB tutorials on how to add labels in Windows forms. I also tried adding different objects such as 'buttons' but still did not work I'm hoping to get an answer on how to add a label to a Windows form that contains a label which will display the current user details
Upvotes: 0
Views: 201
Reputation: 11
I found this set of instructions that helped resolve this issue
Upvotes: 0
Reputation: 54417
I just added this class to a project:
Imports System.Windows.Forms.Design
<ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.MenuStrip)>
Public Class ToolStripLabel
Inherits ToolStripControlHost
Public ReadOnly Property Label As Label
Get
Return DirectCast(Control, Label)
End Get
End Property
Public Sub New()
MyBase.New(New Label)
End Sub
End Class
After building, when I clicked the drop-down to add a new item to a MenuStrip
, there was a Label
option in the list, along with the usual MenuItem
, ComboBox
and TextBox
. After adding one and opening the Properties window, I was able to expand the Label
control and configure it like any other Label
.
Upvotes: 0