Cell click event for Unbound columns

2 posts, 0 answers
  1. Amjad
    Amjad avatar
    1 posts
    Member since:
    Nov 2011

    Posted 26 Dec 2011 Link to this post

    Hi, I am a newbie with telerik controls. I added an unbounded control to my grid. Now I implemented the cellclick event of the grid and trying to get whether the user has clicked on the cell of unbounded column or any other column. For the rest of the columns it is working fine, but it doesn't notify when the user click on the cell of unbounded column. Here is the code, I tried
     private void MasterTemplate_CellClick(object sender, GridViewCellEventArgs e)
            {
                if (e.Column.Name == "IS_INCLUDED")   // My unbounded column Name is IS_INCLUDED
                {
                    MessageBox.Show(e.Row.Cells["IS_INCLUDED"].Value.ToString());
                }
                else
                    MessageBox.Show(e.Column.Name);
            }

    Any help would be appreciated in this regard.
  2. Svett
    Admin
    Svett avatar
    728 posts

    Posted 29 Dec 2011 Link to this post

    Hello Amjad,

    Thank you for writing.

    Indeed I can confirm that the event is not fired in the described scenario. I added this issue in our public issue tracking system and it will be addressed in one of the next releases. Meanwhile, you can work around this case by inheriting RadGridView and adding the following logic:

    public class MyRadGridView : RadGridView
    {
        public override string ThemeClassName
        {
            get
            {
                return typeof(RadGridView).FullName;
            }
            set
            {
                base.ThemeClassName = value;
            }
        }
     
        protected override void OnMouseClick(MouseEventArgs e)
        {
            base.OnMouseClick(e);
     
            RadElement element = this.ElementTree.GetElementAtPoint(e.Location);
            RadCheckBoxEditorElement checkBoxEditorElement = element as RadCheckBoxEditorElement;
     
            if (checkBoxEditorElement != null)
            {
                GridCellElement cell = checkBoxEditorElement.Parent as GridCellElement;
                this.MasterTemplate.EventDispatcher.RaiseEvent<GridViewCellEventArgs>(EventDispatcher.CellClick, cell,
                    new GridViewCellEventArgs(cell.RowInfo, cell.ColumnInfo, this.GridViewElement.ActiveEditor));
     
                this.MasterTemplate.EventDispatcher.ResumeEvent(EventDispatcher.CellClick);
            }
        }
    }

    Your Telerik points have been updated for this report.

    Should you have any other questions, do not hesitate to contact us.

    Kind regards,
    Svett
    the Telerik teamQ3’11 of RadControls for WinForms is available for download (see what's new). Get it today.
Back to Top