This is a migrated thread and some comments may be shown as answers.

Loop thorugh a gridview and get the value of a Checkbox Column

2 Answers 802 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Aristofanes
Top achievements
Rank 1
Aristofanes asked on 31 Oct 2016, 08:10 PM

Hello All, I'm kind a newbie in the WinForms and what I'm trying to do is the following:
I have a RadGridView with a GridViewCheckBoxColumn named "chk" and another GridViewTextBoxColumn named "Serial" and I want to press a button and print the value of “Serial” of the ones from "chk" are checked.
I attached an example of a small GridView with only three values, let’s say I check the first and third, I print “ABCDF” and then print “SerialTest”
Hope anyone can help me or point me with some ideas
Regards!!


2 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 01 Nov 2016, 11:12 AM
Hello ,

Thank you for writing.

The following snippet shows how you can do that:
private void radButton1_Click(object sender, EventArgs e)
{
    foreach (var item in radGridView1.Rows)
    {
        if (item.Cells["bool"].Value != null && (bool)item.Cells["bool"].Value == true)
        {
            Console.WriteLine(item.Cells["Name"].Value);
        }
    }
}

I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
0
Aristofanes
Top achievements
Rank 1
answered on 01 Nov 2016, 08:35 PM

Hello Dimitar tha worked well... thanks a lot for the help

Regards!!!

Tags
GridView
Asked by
Aristofanes
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Aristofanes
Top achievements
Rank 1
Share this question
or