Solved

VB.NET Listbox InvokeRequierd

Posted on 2013-01-07
4
457 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 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 86

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

732 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