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

Cell click event for Unbound columns

1 Answer 46 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Amjad
Top achievements
Rank 1
Amjad asked on 27 Dec 2011, 01:23 AM
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.

1 Answer, 1 is accepted

Sort by
0
Svett
Telerik team
answered on 29 Dec 2011, 03:17 PM
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.
Tags
GridView
Asked by
Amjad
Top achievements
Rank 1
Answers by
Svett
Telerik team
Share this question
or