GridViewCheckBoxColumn

5 posts, 1 answers
  1. Muhammad Naveed
    Muhammad Naveed avatar
    12 posts
    Member since:
    Jul 2017

    Posted 26 Aug 2017 Link to this post

    I want to add a condition on GridViewCheckboxColumn click event, requirement is 'when checkbox is clicked event should be fired.'

    Currently i applied GridViewCell_Click event but it fired on current Cell not particularly on checkbox, and i don't want to use Cell_ValueChanged event according to my programming scenario because it reflects a lot of change in my code.

    What should i do?

    c# programming language

  2. Hristo
    Admin
    Hristo avatar
    1510 posts

    Posted 28 Aug 2017 Link to this post

    Hi Muhammad,

    Thank you for writing.

    Note that most of the forum threads are reviewed by Telerik representatives. However, a post in the forum doesn't guarantee you a response from the Telerik support team. If you think that Telerik needs to review your project and/or files, start a new support ticket.

    Regarding your actual question, if I understand you correctly you would like to detect clicks on the check mark. You can achieve your task by handling the MouseDown event of the grid: 
    private void RadGridView1_MouseDown(object sender, MouseEventArgs e)
    {
        RadGridView grid = (RadGridView)sender;
        RadCheckmark checkMark = grid.ElementTree.GetElementAtPoint(e.Location) as RadCheckmark;
        if (checkMark != null)
        {
            //...
        }
    }

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Muhammad Naveed
    Muhammad Naveed avatar
    12 posts
    Member since:
    Jul 2017

    Posted 29 Aug 2017 in reply to Hristo Link to this post

    Hi Hristo,

    Thanks for your reply.

    I tried same code but same result received,

    my scenario is i would like to update the datetime when checkbox is clicked on that particular cell grid. currently it updates the datetime even when i clicked on a cell not on checkbox.

  4. Answer
    Hristo
    Admin
    Hristo avatar
    1510 posts

    Posted 29 Aug 2017 Link to this post

    Hi Muhammad,

    Thank you for writing.

    The code snippet I sent you performs a check for the RadCheckMark type. The if statement will be evaluated to true only when clicking on the check mark. 

    I have extended the example to demonstrate how you can get the logical row object and change any of the other cell values when clicking on the checkbox: 
    private void RadGridView1_MouseDown(object sender, MouseEventArgs e)
    {
        RadGridView grid = (RadGridView)sender;
        RadCheckmark checkMark = grid.ElementTree.GetElementAtPoint(e.Location) as RadCheckmark;
        if (checkMark != null)
        {
            GridDataRowElement row = checkMark.FindAncestor<GridDataRowElement>();
            if (row != null)
            {
                GridViewCellInfo dateCell = row.RowInfo.Cells["Date"];
                DateTime dt = ((DateTime)dateCell.Value).AddDays(1);
                dateCell.Value = dt;
            }
        }
    }

    I am also attaching a short video showing the result on my end.

    I hope this helps. Please let me know if you have other questions.

    Regards,
    Hristo
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  5. Muhammad Naveed
    Muhammad Naveed avatar
    12 posts
    Member since:
    Jul 2017

    Posted 30 Aug 2017 in reply to Hristo Link to this post

    Thanks Hristo for a usefull reply. 

Back to Top