[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

VB.NET Listbox InvokeRequierd

Posted on 2013-01-07
4
Medium Priority
?
465 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
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…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

650 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