[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Change color of listview items on a seperate thread vb.net

Posted on 2009-12-22
Medium Priority
Last Modified: 2012-05-08
How do I change the color of a listview item, if the listview is on a different thread than the function that's calling the color change?

My code for the listview is:
OrderView.Items.Item(ListViewIndex).ForeColor = Color.Blue

Thanks for your help!
Question by:slightlyoff

Accepted Solution

gsterk earned 2000 total points
ID: 26107962
In order to interact with a control from a thread other then the one that created the control, you must use either the Control.Invoke or Control.BeginInvoke method.

    Private Delegate Sub Invoker()

    Private Sub Update()
        If OrderView.InvokeRequired Then
            Dim method As New Invoker(AddressOf Update)
            OrderView.Items.Item(ListViewIndex).ForeColor = Color.Blue
        End If
    End Sub


Author Closing Comment

ID: 31669147
Thank you!  I appreciate the help!

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

872 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