Clearing a combobox

Hi, I'm using VB2005, WinForms. I have a DataGridView and a set of Controls (i.e. Textboxes, ComboBoxes, etc) on one of my Forms. For the ComboBoxes, I load the data from the DataGridView in the following manner, which works fine - no problem there.

cbxDepartment.SelectedItem = dgvUserList.Rows(intRowIndex).Cells("DepartmentName").Value.ToString

However, once a value has been loaded into the "Text" property of the ComboBox, I cannot clear it to a "blank" value. I can replace it by reloading a new value, but I cannot do the following (it has no effect).

cbxDepartment.Text = String.Empty       ' Not working
cbxDepartment.Text = ""            ' Not working either

Is there a way to clear the Text value once the ComboBox has a Text value visible?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Éric MoreauSenior .Net ConsultantCommented:
have you tried: cbxDepartment.SelectedItem = -1
Try cbxDepartment.SelectedIndex = -1
Jaime OlivaresSoftware ArchitectCommented:
Correct way is:
cbxDepartment.SelectedItem = Nothing
cbxDepartment.SelectedIndex = -1


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

Mr_FulanoAuthor Commented:
Both solutions worked. One contributor provided more than one option, which I took into consideration while splitting the points. -- Thank you both for the great help!
Éric MoreauSenior .Net ConsultantCommented:
I don't understand why I haven't got any points here since I was the first to propose this solution! Really strange!
Jaime OlivaresSoftware ArchitectCommented:

Maybe you didn't notice but your proposal:
cbxDepartment.SelectedItem = -1
should be:
cbxDepartment.SelectedItndex = -1

MSDN documentation states:
The object that is the currently selected item or nullNothingnullptra null reference (Nothing in Visual Basic) if there is no currently selected item.
A zero-based index of the currently selected item. A value of negative one (-1) is returned if no item is selected.

So, your proposal should work unless by any chance one of the values in combo is -1. But it is against MSDN documentation.

Éric MoreauSenior .Net ConsultantCommented:
how come Xygxag who posted the same I did after me got points?
Jaime OlivaresSoftware ArchitectCommented:
it is not the same solution:

 cbxDepartment.SelectedItem = -1
 cbxDepartment.SelectedIndex = -1
Éric MoreauSenior .Net ConsultantCommented:
my mistake. sorry
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.