i need help with combobox in vb.net.
i try to add several columns in the combo,so i want when i select one item in the combo (this item is composed from 3 words for example),so i want the text in the combobox not to be composed from these 3 words but from one of these 3 word.
this is what i need.
so to test the combobox,i tried when i select an item in the combobox (what ever this item) to set manually the text in the combo and that is the impossible,so i noticed that when i select an item in the combo box ,it's been selected in the combo so it's impossible to change the selection so i tried :combobox1.SelectionLength = -1 but it throw an exception and i fail.and i tried everything i can and no result.
so i know the key is to unselect the selection in the combo,then set manually the text,it's like to click in the textarea of the combo to unselect the item selected.
so i need your experience.
thank you for help.
This is what you need, it's a multi-column combobox.
And for your problem with unselecting a selected item, use
combobox1.SelectedIndex = -1 .
thank you ,but first iconCombobox is not defined and i add the dll from the site but it doesn't work and i will try again.
and about combobox1.SelectedIndex = -1 ,for example:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As Integer
For i = 0 To 10
ComboBox1.Items.Add("daniweb " & i)
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
ComboBox1.SelectedIndex = -1
ComboBox1.Text = "Oxiegen"
it doesn't work ,all i acheive that a blan combobox.
about the combo ,i had a project on university that i need combo ,so my solution that to add 2 combo one on another and play with visibility ,but i don't accept that ,i want to act like real programmer so that's my solution 2 combo and i had second solution a timer tick ,but if i had 10 combo => 10 timer also it isn't a good solution so after hard working yes i need like iconcombo posted in your link but it's a custom control that others create it ,so i want a solution in the standard combobox.
again thank you.
Unfortunatily, the standard combobox does not support true multiple columns. You have to go custom for that.
There is one solution that I found a while back ago, when I was researching readonly comboboxes.
It involves one combobox and one textbox.
Put the textbox on top of the combobox, set the width to cover all of the combobox except the dropdown-arrow, and set it's visibility to false.
Private Sub ComboBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.Click TextBox1.Visible = False End Sub Privte Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged If ComboBox1.SelectedIndex > -1 Then TextBox1.Visible = True TextBox1.Text = ComboBox1.SelectedItem.ToString().SubString(0, ComboBox1.SelectedItem.ToString().IndexOf("<delimiter>")) End If End Sub
yes it's another solution thank you,and unfortunatily the multiple columns combobox it's very powerful and it's a must.so the custom combobox is the solution and this the first time after your reply that i know that we can add custom controls so thank you very much.
Glad to be of help. :)
Please mark this thread as solved.