Changing values in a listbox 
Author Message
 Changing values in a listbox

I have a listbox with various 'values' which when clicked, presents this
value into a textbox for the user to change.  All works well, however I want
my program to change the selected item in the listbox to that what the user
has typed in the textbox.

I can't find anywhere in the documentation about changing values already in
place.  Any ideas?

TIA



Sat, 17 Sep 2005 01:22:46 GMT  
 Changing values in a listbox
Hello Jason,


Quote:
> I have a listbox with various 'values' which when
> clicked, presents this value into a textbox for
> the user to change.  All works well, however I want
> my program to change the selected item in the listbox
> to that what the user has typed in the textbox.

\\\
Private Sub Button1_Click( _
    ByVal sender As System.Object, _
    ByVal e As System.EventArgs _
) Handles Button1.Click
    Me.ListBox1.Items(Me.ListBox1.SelectedIndex) = _
        Me.TextBox1.Text
    Me.ListBox1.Refresh()
End Sub

Private Sub ListBox1_SelectedIndexChanged( _
    ByVal sender As System.Object, _
    ByVal e As System.EventArgs _
) Handles ListBox1.SelectedIndexChanged
    Try
        Me.TextBox1.Text = Me.ListBox1.SelectedItem.ToString()
    Catch
    End Try
End Sub
///

Regards,
Herfried K. Wagner



Sat, 17 Sep 2005 01:31:01 GMT  
 Changing values in a listbox
Thanks again Herfried.



Quote:
> Hello Jason,


> > I have a listbox with various 'values' which when
> > clicked, presents this value into a textbox for
> > the user to change.  All works well, however I want
> > my program to change the selected item in the listbox
> > to that what the user has typed in the textbox.

> \\\
> Private Sub Button1_Click( _
>     ByVal sender As System.Object, _
>     ByVal e As System.EventArgs _
> ) Handles Button1.Click
>     Me.ListBox1.Items(Me.ListBox1.SelectedIndex) = _
>         Me.TextBox1.Text
>     Me.ListBox1.Refresh()
> End Sub

> Private Sub ListBox1_SelectedIndexChanged( _
>     ByVal sender As System.Object, _
>     ByVal e As System.EventArgs _
> ) Handles ListBox1.SelectedIndexChanged
>     Try
>         Me.TextBox1.Text = Me.ListBox1.SelectedItem.ToString()
>     Catch
>     End Try
> End Sub
> ///

> Regards,
> Herfried K. Wagner



Sat, 17 Sep 2005 01:39:08 GMT  
 Changing values in a listbox
Herfried,

I now have the follow code which works fine...

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click

lstOutcomes.Items.Add("New Item")

End Sub

Private Sub txtMemberDescription_TextChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles txtMemberDescription.TextChanged

lstOutcomes.Items(lstOutcomes.SelectedIndex) = txtMemberDescription.Text

lstOutcomes.Refresh()

End Sub

Private Sub lstOutcomes_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles lstOutcomes.SelectedIndexChanged

Try

txtMemberDescription.Text = lstOutcomes.SelectedItem.ToString

Catch

End Try

End Sub

However I've noticed there is a significant pause when I first add an item
in the listbox and then click on it.  Why is this?

TIA



Quote:
> Hello Jason,


> > I have a listbox with various 'values' which when
> > clicked, presents this value into a textbox for
> > the user to change.  All works well, however I want
> > my program to change the selected item in the listbox
> > to that what the user has typed in the textbox.

> \\\
> Private Sub Button1_Click( _
>     ByVal sender As System.Object, _
>     ByVal e As System.EventArgs _
> ) Handles Button1.Click
>     Me.ListBox1.Items(Me.ListBox1.SelectedIndex) = _
>         Me.TextBox1.Text
>     Me.ListBox1.Refresh()
> End Sub

> Private Sub ListBox1_SelectedIndexChanged( _
>     ByVal sender As System.Object, _
>     ByVal e As System.EventArgs _
> ) Handles ListBox1.SelectedIndexChanged
>     Try
>         Me.TextBox1.Text = Me.ListBox1.SelectedItem.ToString()
>     Catch
>     End Try
> End Sub
> ///

> Regards,
> Herfried K. Wagner



Sat, 17 Sep 2005 01:51:36 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Bind Listbox w/ No Value Change

2. Changing Listbox value when...

3. Changes to Display values w/o changing database values

4. VB3: Setting listbox based on value of other listbox

5. Combobox or Listbox: separting key values from display values

6. Changing the listbox font name shrinks the listbox

7. Change label caption in userform on change of dropdown listbox

8. combobox value: can not change value

9. Calulated fields changes control values back to original values

10. COMBOBOX.BOUNDTEXT VALUE CHANGES TO DIFFERENT FIELD VALUE

11. Change font formatting changes value of other cell

12. Storing Listbox values in tables and recalling

 

 
Powered by phpBB® Forum Software