?
Solved

VB.NET Listbox InvokeRequierd

Posted on 2013-01-07
4
Medium Priority
?
460 Views
Last Modified: 2013-01-20
Hi, I have a problem..
this code works..
 Private Delegate Sub SetTextBoxTextInvoker(ByVal text As String)

  Private Sub SetTextBoxCom01(ByVal text As String)
        'If Me.uxCom1txt.InvokeRequired Then
        '    Me.uxCom1txt.Invoke(New SetTextBoxTextInvoker(AddressOf SetTextBoxCom01), text)
        'Else
        '    Me.uxCom1txt.ADD(text)
        'End If

Open in new window


But I need to change to an listbox..
Can´t figure out how to get it to work..

        If LISTBOX1.add.InvokeRequired Then
            Me.LISTBOX1.Invoke(New SetTextBoxTextInvoker(AddressOf SetTextBoxCom01), text)
        Else
            Me.LISTBOX1.Text = text
        End If

Open in new window



VB.NET Visual studio 2010
0
Comment
Question by:kavvis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 1000 total points
ID: 38751217
A ListBox doesn't have a Text property. Are you sure you didn't intend to add the incoming parameter to the Items collection?

e.g.

        If LISTBOX1.add.InvokeRequired Then
            Me.LISTBOX1.Invoke(New SetTextBoxTextInvoker(AddressOf SetTextBoxCom01), text)
        Else
            Me.LISTBOX1.Items.Add(text)
        End If

Open in new window

0
 

Author Comment

by:kavvis
ID: 38751634
Hi I just tried to show an exampel.. I rally don"t know The syntax... :) that"s why I need help
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 1000 total points
ID: 38751906
You can do:
    Private Sub AddToListBox(ByVal text As String)
        If ListBox1.InvokeRequired Then
            Me.ListBox1.Invoke(New Action(Of String)(AddressOf AddToListBox), New Object() {text})
        Else
            Me.ListBox1.Items.Add(text)
        End If
    End Sub

Open in new window

0
 

Author Closing Comment

by:kavvis
ID: 38798206
It´s seems to work.. But somehow I get problem when I trie to use the data later on.. but I have to se it..
0

Featured Post

Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question