Results 1 to 13 of 13

Thread: [RESOLVED] In Vb.net I need to add a message box to current code with Red backcolor

Hybrid View

  1. #1
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: In Vb.net I need to add a message box to current code with Red backcolor

    Code:
    Dim found As Boolean = False
    For Each row As DataGridViewRow In Me.LotsDataGridView.Rows
        For Each c As DataGridViewCell In row.Cells
            If c.Style.BackColor = Color.Red Then found = True
        Next
    Next
    
    If found Then
        MessageBox.Show("found red cell")
    End If

  2. #2
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,631

    Re: In Vb.net I need to add a message box to current code with Red backcolor

    Quote Originally Posted by .paul. View Post
    Code:
    Dim found As Boolean = False
    For Each row As DataGridViewRow In Me.LotsDataGridView.Rows
        For Each c As DataGridViewCell In row.Cells
            If c.Style.BackColor = Color.Red Then found = True
        Next
    Next
    
    If found Then
        MessageBox.Show("found red cell")
    End If
    Another option that will terminate the loops once the first red cell is found:

    Code:
    Dim found As Boolean = False
    For Each row As DataGridViewRow In Me.LotsDataGridView.Rows
        For Each c As DataGridViewCell In row.Cells
            If c.Style.BackColor = Color.Red Then
                found = True
                MessageBox.Show("found red cell")            
                Exit For
            End If
        Next
        If found = True Then
            Exit For
        End If
    Next

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width