Checkbox click

9 posts, 1 answers
  1. Henk Wallinga
    Henk Wallinga avatar
    1 posts
    Member since:
    Apr 2010

    Posted 15 Apr 2010 Link to this post

    Hi,
    I have a gridview with cells bound to a datasource. In addition I added a checkboxcolumn as follows:

     

    this

     

    .radGVMeldinger.MasterGridViewTemplate.Columns.Add(new GridViewCheckBoxColumn());

    I want this grid not editable, only the checkbox.
    I made the following code snippet:

     

    private

     

    void radGVMeldinger_CellClick(object sender, GridViewCellEventArgs e)

     

    {

     

        if (e.RowIndex >= 0)

     

        {

     

            if (this.radGVMeldinger.MasterGridViewTemplate.Rows[e.RowIndex].Cells[12].Value.ToString() != "True")

     

            {

                radGVMeldinger.MasterGridViewTemplate.Rows[e.RowIndex].Cells[12].Value =

    true;

     

            }

     

            else

     

     

     

     

            {

                radGVMeldinger.MasterGridViewTemplate.Rows[e.RowIndex].Cells[12].Value =

    false;

     

            }

        }

    }

     

    Everything works fine, unless the fact that when I click the checkbox column this event doesn't fire.
    This event fires when I click on every other column.
    Has anyone a solution?
    Regards,
    /Henk

  2. Answer
    Jack
    Admin
    Jack avatar
    2335 posts

    Posted 15 Apr 2010 Link to this post

    Hello Henk Wallinga,

    This event doesn't fire for checkbox cells because they contain a permanent editor which catches this event. You should use the GridViewColumn.ReadOnly property to specify which columns are read only.

     

    Greetings,
    Jack
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Marco
    Marco avatar
    3 posts
    Member since:
    Jul 2010

    Posted 23 Oct 2010 Link to this post

    I have the same problem: I have a checkbox column, it's the only one editable column (not read only). The ValueChanged and/or the cellValueChanged not fires.
    I need to know if on my grid I have some line checked but I can't.
    I try using a timer (!!!!) to count the checked lines every second, and I see that if I stay on the checked line it's counted as not checked... I need to move on another line to see the change!!
    Some help?
  5. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 23 Oct 2010 Link to this post

    Hello Marco,

    The ValueChanged event will fire every time you change the value in a cell, but that value will not be applied in the cell until you move from that cell, because it is waiting for confirmation, you could always cancel the operation, or change the value.
    That's why when you move out of that cell, and the value has been changed, the CellValueChanged event will fire, and the value will be changed.
    You can change this behavior by registering to the ValueChanged event and using this:
    void radGridView1_ValueChanged(object sender, EventArgs e)
    {
        // this will end the edit operation and force a value change to occur
        radGridView1.EndEdit();
        // uncomment this line if you want to be in editing mode after the value change
        // radGridView1.BeginEdit();
    }

    I will also attach a full example in the following lines, if you need it:
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Windows.Forms;
    using Telerik.WinControls.UI;
     
    public partial class Form1 : Form
    {
        private RadGridView radGridView1;
     
        public Form1()
        {
            InitializeComponent();
            this.Controls.Add(radGridView1 = new RadGridView());
            radGridView1.Dock = DockStyle.Fill;
            radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
     
            var list = new List<Test>();
            for (int i = 0; i < 10; i++)
            {
                list.Add(new Test { Id = i, Checked = i % 2 == 0 });
            }
     
            radGridView1.ValueChanged += new EventHandler(radGridView1_ValueChanged);
            radGridView1.CellValueChanged += new GridViewCellEventHandler(radGridView1_CellValueChanged);
            radGridView1.DataSource = list;
        }
     
        void radGridView1_CellValueChanged(object sender, GridViewCellEventArgs e)
        {
            Debug.WriteLine("CellValueChanged");
        }
     
        void radGridView1_ValueChanged(object sender, EventArgs e)
        {
            Debug.WriteLine("ValueChanged");
            radGridView1.EndEdit();
            //radGridView1.BeginEdit();
        }
    }
     
    public class Test
    {
        public int Id { get; set; }
     
        public bool Checked { get; set; }
    }

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga
  6. Marco
    Marco avatar
    3 posts
    Member since:
    Jul 2010

    Posted 25 Oct 2010 Link to this post

    Great! It works!!!
    Thank you very much!
  7. Rama Krishna
    Rama Krishna avatar
    2 posts
    Member since:
    Jul 2012

    Posted 12 Dec 2012 Link to this post

    Hello,

    I have the same problem. I have a radgridview that will autofilled by datasource from database. one of the column in binary so it will automatically creates a checkbox column. My requirement is to switch between select and deselect of the checkbox if user clicks on any part of that row. I am able to capture the cellclick event when users click anywhere on the row except the checkbox cell. I would like to know how can I capture cellclick event when user clicks on a checkbox cell.

    Thanks in advance!
    Rama
  8. Svett
    Admin
    Svett avatar
    728 posts

    Posted 17 Dec 2012 Link to this post

    Hello Rama,

    I did not manage to reproduce the issue with the latest release Q3 2012 SP1. The CellClick event is fired when the checkbox editor is clicked. Could you share more information regarding the version that you are using and how you initialize and use RadGridView?

    Greetings,
    Svett
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
  9. Rama Krishna
    Rama Krishna avatar
    2 posts
    Member since:
    Jul 2012

    Posted 02 Jan 2013 Link to this post

    Hello Svett,

    I think I am using Q1 2012 SP1. I am initializing the Radgridview by executing a storedprocedure and assinging result as datasource. I am not having any pre added columns to the radgriedview.
    One of the columns in the result set is binary which automatically converted to checkbox column on Radgridview after binding. I am trying to check and uncheck the checkbox based on cellclick event, but auto genereated Checkbox column is not responding to the cellclick event. I think I need to use the latest release.

    Thanks,
    Rama
  10. Svett
    Admin
    Svett avatar
    728 posts

    Posted 07 Jan 2013 Link to this post

    Hi Rama,

    Thank you for writing.

    I did not manage to reproduce the issue with 2012.1.321.40 (Q1 2012 SP1). It seems that there is something specific that I am missing. Could you send a sample project where the issue occurs? This will help us to understand your scenario from first hand.

    Kind regards,
    Svett
    the Telerik team
    Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
Back to Top
UI for WinForms is Visual Studio 2017 Ready