We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


Use addrange with datagrid item.cell

kdeutsch asked
Medium Priority
Last Modified: 2012-08-13
What I have is a datagrid with 7 columns in it.  Currently I have it so that if there is a no in cell 7 it colors the name red.  What I really need is a way to call out columns 2 -7 if there are any no's it colors the name red.  I have tried using the following with no luck keeps giving me blue underlines ander the range numbers.  How can I call our columns 2 - 7 and color name red if they have a no.

If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
            If e.Item.Cells.AddRange(2 - 7).Text = "No" Then
                e.Item.Cells(0).BackColor = System.Drawing.Color.Tomato
            End If
            If e.Item.Cells(7).Text = "Yes" Then
                e.Item.Cells(0).BackColor = System.Drawing.Color.Green
            End If
        End If

Open in new window

Watch Question

add range only adds cells, you need to loop through the cells to do that

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.