-
Jun 14th, 2013, 11:42 AM
#1
Thread Starter
Member
Visual Basic Drop Down List Default Text (Not Menu Item)
Ok first off I have tried to search for the answer to this but I'm not finding anything (even though I'm sure it's been answered before) I will admit that I'm new to Visual Basic but I have been studying and trying to learn but it's proving to be harder than I thought...
What I have is a combobox that is a drop down list so that the user can only make a selection not type in their own information.
The Issue I'm having is I want to make the combo box have a coupe of items that the user can select but before the user selects an item I want the text for the combo box display what the combo box is.
Ex.
Combobox name:
Sales Rep
User clicks the combo box
and it displays a list of names (but not the Sales rep text)
I would think that this is pretty simple but when it comes to Visual Basic I have learned that this is not always the case...
Thanks in advance for helping a new comer to programming.
Ryan
-
Jun 14th, 2013, 12:48 PM
#2
Re: Visual Basic Drop Down List Default Text (Not Menu Item)
I want the text for the combo box display what the combo box is.
No you don't! Trust me. Use a label if there is a genuine need for a visual indication of what a control represents.
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Jun 14th, 2013, 01:20 PM
#3
Thread Starter
Member
Re: Visual Basic Drop Down List Default Text (Not Menu Item)
Originally Posted by dunfiddlin
No you don't! Trust me. Use a label if there is a genuine need for a visual indication of what a control represents.
Lol ok well could you explain why I don't want to just so I know.
I did figure out a solution. Here's what I ended up doing.\
Code:
Public Class mainWindow
Private Sub mainWindow_Load(sender As Object, e As EventArgs) Handles Me.Load
cbxRep.Items.Insert(0, "Sales Rep")
cbxRep.Text = "Sales Rep"
End Sub
Private Sub cbxRep_Enter(sender As Object, e As EventArgs) Handles cbxRep.Enter
cbxRep.Items.RemoveAt(0)
End Sub
Private Sub cbxRep_Leave(sender As Object, e As EventArgs) Handles cbxRep.Leave
If cbxRep.Text = "Sales Rep" Or "" Then
cbxRep.Items.Insert(0, "Sales Rep")
cbxRep.Text = "Sales Rep"
Else
cbxRep.Items.ToString()
End If
End Sub
End Class
Other than the "Sales Rep" text not returning if you don't select a Sales Persons name and than click somewhere else.
-
Jun 14th, 2013, 06:44 PM
#4
Re: Visual Basic Drop Down List Default Text (Not Menu Item)
Lol ok well could you explain why I don't want to just so I know.
Well one reason would be that there's a member of this forum who hates it even more than me and will have a hissy fit and nobody wants to see that again!
But it is a very unprofessional look and it can be irritating for the savvy user and confusing for the inexperienced user. If nothing else, it means you're spending/wasting time trying to find solutions to problems that have no obvious reason to exist in the first place. (And yes, I do know professional coders who spend all day doing just that in order to justify their continued employment but that doesn't mean you should!)
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|