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

About GridViewCell

2 Answers 78 Views
GridView
This is a migrated thread and some comments may be shown as answers.
jeremy
Top achievements
Rank 1
jeremy asked on 23 May 2011, 04:16 AM
Hi,
   I have a problem with GridViewCell, I think it is also the same with GridViewRow. I use silverlight  controls  2011 Q1.
   In my project, the code below:

   
this.RADGRIDWIEW.AddHandler(GridViewCell.MouseLeftButtonUpEvent, new MouseButtonEventHandler(Cell_Click), true);
    private void Cell_Click(object sender, MouseButtonEventArgs e)
    {
         MessageBox.Show("xxxxx").
    }
 
      When I click a cell in the gridview, the messbox is showed. but when I  cilck (drag) the scrollViewer in the gridview, the messagebox also be showed. I do not need it. How to solve it. thanks!

2 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 25 May 2011, 11:54 AM
Hi jeremy,

In order to execute the logic (showing the ComboBox in your case) only for the data GridViewCells, you should change your code like this:

private void Cell_Click(object sender, MouseButtonEventArgs e)
{
    var senderElement = (FrameworkElement)e.OriginalSource;
    var clickedCell = senderElement.ParentOfType<GridViewCell>();
 
    if (clickedCell != null)
    {
        // execute logic
        MessageBox.Show("xxxxx");
    }       
}

This way you choose only the desired elements to call the logic.

Best wishes,
Didie
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
0
jeremy
Top achievements
Rank 1
answered on 30 May 2011, 03:08 AM
Hi Didie,
    Thanks for you help. It works fine.
Best regard.
Jeremy.
 
Tags
GridView
Asked by
jeremy
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
jeremy
Top achievements
Rank 1
Share this question
or