Solved

VB.NET Listbox InvokeRequierd

Posted on 2013-01-07
4
443 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
  • 2
4 Comments
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 250 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 85

Accepted Solution

by:
Mike Tomlinson earned 250 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

937 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now