Click here to Skip to main content
15,073,488 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone.

This is a bit of an unusual problem.

I have a ComboBox (with DropdownStyle = DropDown)
The user can either type something in the ComboBox or select an item from the drop down list.
If they select a specific item ie "Painting as per Quotation ......." I would like to change the selected item to say "Painting as per Quotation Q2020-001". The Quotation Number is retrieved from another ComboBox.

The code that I'm using (see below) does not change anything - the Combobox remains unchanged.

Could anyone advise if this is even possible and how I could achieve my desired result.

Many Thanks

What I have tried:

Private Sub cbo_Desc_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbo_Desc.SelectedIndexChanged,
       Dim NewText As String = ""

       If cbo_Desc.Text = "Painting as per Quotation ......." Then
           NewText = cbo_Desc.Text.Replace(".......", cbo_Quotation_Number.Text)
           cbo_Desc.Text = NewText
       End If

 End Sub
Posted
Updated 28-Jul-20 4:38am

1 solution

I do not think setting the text of the ComboBox will change the value of the selected item. You need to get the actual item reference that is selected (from the Items collection) and change its text.
   
Comments
Darrell de Wet 28-Jul-20 11:07am
   
Makes sense. Thanks for the quick response.

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