combobox use

Hi you experts

i wandering if a combobox that contain information be able to do not deleted from the user but otherwise add more info if it want it

i mean
XXKU-3322-94  (that it contains)
i dont want to delete it but add more is aviable
is that posible
tsm you experts
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.

You mean smth like this?:
Dim lastIndex As Long

Private Sub Combo1_Change()
  If lastIndex = -1 Then Exit Sub
  Dim s As String
  s = Combo1.Text
  Combo1.List(lastIndex) = s
  Combo1.ListIndex = lastIndex
  Combo1.SelStart = Len(s)
End Sub

Private Sub Combo1_Click()
   lastIndex = Combo1.ListIndex
End Sub

Private Sub Form_Load()
   For i = 0 To 9
       Combo1.AddItem "XXKU-3322-" & (i + 94)
   Next i
   lastIndex = 0
   Combo1.ListIndex = 0
End Sub

Open in new window

Oops, sorry, posted above from VB classic area but somehow it appears in .Net. VB.Net version:
    Private lastIndex As Integer = -1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        For i = 0 To 9
            ComboBox1.Items.Add("XXKU-3322-" & (i + 94))
        Next i
        lastIndex = 0
        ComboBox1.SelectedIndex = 0
    End Sub   Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        lastIndex = ComboBox1.SelectedIndex
    End Sub

    Private Sub ComboBox1_TextUpdate(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.TextUpdate
        If lastIndex > -1 Then
            Dim s = ComboBox1.Text
            ComboBox1.Items(lastIndex) = s
            ComboBox1.SelectionStart = s.Length
        End If
    End Sub

Open in new window

Hello edo60,
While it is possible to do so it doesn't seem to make much sense to add items to a combobox at runtime. It is more common to set the entire list. The reason for doing so isn't in the difficulty of adding an item but of selecting the item to add. Even if the items list should consist of a number of standard items plus a few that are added depending upon other factors I would recommend to assemble the list in an array and then assign the array to the combobox. The resulting code will be neater and easier to modify or trouble-shoot.
As an alternative it is possible to permit the user to make an entry which isn't on the list. For this purpose you can set the MatchRequired property to False.

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
ErnestoAuthor Commented:
i try to explain this
i dont want the user delete a string that is combined by a proyecto and requisición
like that
Proyecto:  1010
Requisición: XXIUIWW-TERS

the result of orden de compra is  proyecto + requisicion + a control number

i want the user only add the control number to the combobox orden de compra, but
do not delete the previous string

Orden de compra: 1010-XXIUIWW-TERS-001

is that posible
It is hard to find something that isn't possible, but I wouldn't recommend implementation. The way to do it would have to be that the user over-writes the existing with "1" and the program changes that into 1010 XXIUIWW-TERS-001 immediately. The better way should be do show all components of the number in separate textboxes and then display the entire construct somewhere else again. It might be worth your while to examine the possibility that the user has no interest in the number you are taking so much pain to show to him. He is likely to focus on selecting the correct project and requisition and add an index. The fact that all of this serves as a document ID may not gain any consequence until the document is produced.
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.