Click here to Skip to main content
15,901,035 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello everyone!

How can i "remove" the details of comboBox?
***I'm getting the details of my database into the comboBox

I tried this code :

VB
comoboBox1.text = "" 
comoboBox1.text = 0


My comboBox contains, for exemple this string = "QWE"
When i tried this code down here, the rsult is the same = "QWE"
VB
 if comoboBox1.text <> "" then '//for string
    comoboBox1.text = "" '/// result: QWE
            or
    comoboBox1.text = 0 '/// result: QWE
end if
                                     OR
 if comoboBox1.text <> 0 then '//for string
    comoboBox1.text = 0 '/// result: QWE
            or
    comoboBox1.text = "" '/// result: QWE
end if
</pre>



In visual studio, in the menu I have "Build" and I've done, clean and Build... but nothing.


If you help me,I will appreciate.

With best regards,
Nillo123.
Posted

Check the SelectedIndex[^] property and set it to -1 ;)
 
Share this answer
 
Comments
Nillo123 26-Jun-13 7:11am    
If Len(cbx_USER_ass.Text) <> 0 Then
cbx_USER_ass.Text = Nothing
cbx_USER_ass.Enabled = False
End If
You can try :

C#
comboBox1.Items.Clear();
 
Share this answer
 
Comments
Nillo123 25-Jun-13 6:37am    
When this reached the comboBox1.items.clear --> this error appear, msg of exception:

An unhandled exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll
Additional information: Conversion from string "Data Source=..." to type 'Long' is not valid.

but thanks anyway :) ;)
VB
If Len(cbx_USER_ass.Text) <> 0 Then
            cbx_USER_ass.Text = Nothing
            cbx_USER_ass.Enabled = False
End If
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900