Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Change row color in listview

Posted on 2014-03-30
6
Medium Priority
?
542 Views
Last Modified: 2014-03-31
I am not asking for the answer on this.  I want to make that very clear.  I am looking for direction on this.  What I need to know if its possible to do is look at a sql database and if the "Arrived" time is over 5 mins, change the color on the row of the list box.  Again I have not started working on this, I have some knowledge on how to change a row color on an individual item in the listview I just cant think of an efficent way to have a timer look at a database and see if the time on open calls are greater than 5 mins.  I am just looking for some help on this.  Any responses would be appreciated.  I am programing in VB.NET not C++
0
Comment
Question by:russell12
[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
  • 2
  • 2
6 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 39967230
Are you working with ASP.NET web site, Windows Forms, WPF...?
0
 
LVL 2

Author Comment

by:russell12
ID: 39967240
Winforms vs2013.  Coding in vb.net
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 39967252
You should be able to set the ListViewItem.BackColor to what you need.
0
Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.

 
LVL 23

Accepted Solution

by:
Jens Fiederer earned 2000 total points
ID: 39967291
If you could fetch the data at the beginning and STORE it in one of the rows, you'd only need to make one database call, and then have the timer compare the current time against stored data, somewhat like:


Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        ListView1.View = View.Details
        ' Create three items and three sets of subitems for each item. 
        Dim item1 As New ListViewItem("item1", 0)
        ' Place a check mark next to the item.
        item1.Checked = True
        item1.SubItems.Add(DateTime.Now.AddHours(1))
        item1.SubItems.Add("2")
        item1.SubItems.Add("3")
        Dim item2 As New ListViewItem("item2", 1)
        item2.SubItems.Add(DateTime.Now.AddSeconds(10))
        item2.SubItems.Add("5")
        item2.SubItems.Add("6")
        Dim item3 As New ListViewItem("item3", 0)
        ' Place a check mark next to the item.
        item3.Checked = True
        item3.SubItems.Add(DateTime.Now.AddHours(1))
        item3.SubItems.Add("8")
        item3.SubItems.Add("9")

        ' Create columns for the items and subitems. 
        ' Width of -2 indicates auto-size.
        ListView1.Columns.Add("Item Column", -2, HorizontalAlignment.Left)
        ListView1.Columns.Add("Time", -2, HorizontalAlignment.Left)
        ListView1.Columns.Add("Column 3", -2, HorizontalAlignment.Left)
        ListView1.Columns.Add("Column 4", -2, HorizontalAlignment.Center)

        'Add the items to the ListView.
        ListView1.Items.AddRange(New ListViewItem() {item1, item2, item3})
        t.Interval = 1000
        AddHandler t.Tick, AddressOf OnTimedEvent
        t.Start()
    End Sub

    Private Sub OnTimedEvent(source As Object, e As EventArgs)
        For Each i As ListViewItem In ListView1.Items
            If DateTime.Now > DateTime.Parse(i.SubItems(1).Text) Then
                i.BackColor = Color.AliceBlue
            End If
        Next
    End Sub

Open in new window

0
 
LVL 2

Author Closing Comment

by:russell12
ID: 39968359
I can not believe i didnt think of doing it this way!  I appreciate your help.
0
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 39968399
My pleasure, thanks for the quick feedback
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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 …
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

704 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