4

I have a checkbox column, and it is working just as intended.

How do I "get" the selected rows ?

I'd like to get the ones that are checked and run a method using another field of the same row.

2
  • Are you dynamically populating the checkboxes or are they static? Commented May 21, 2010 at 14:13
  • glad to hear the problem solved - cheers! Commented May 21, 2010 at 20:35

2 Answers 2

7

I believe the answer would look something like:

foreach (DataGridViewRow item in DataGridName.Rows) 
{
    if (((bool)(item.Cells["name_of_column"].Value)) == true)
    {
        MyMethod(item.Cells["name_od_the_other_field"].Value);
    }    
}
Sign up to request clarification or add additional context in comments.

Comments

2

Solved it through:

foreach (DataGridViewRow item In DataGridName.Rows)
{

    If (item.Cells(0).Value)
    {
        MyMethod(item.Cells(0).Value);
    }   

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.