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

3 posts, 1 answers
  1. Aristofanes
    Aristofanes avatar
    2 posts
    Member since:
    Oct 2016

    Posted 31 Oct Link to this post

    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. Answer
    Dimitar
    Admin
    Dimitar avatar
    1408 posts

    Posted 01 Nov Link to this post

    Hello Aristofanes,

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Aristofanes
    Aristofanes avatar
    2 posts
    Member since:
    Oct 2016

    Posted 01 Nov in reply to Dimitar Link to this post

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

    Regards!!!

Back to Top