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

[Solved] Click on column header

7 Answers 202 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Gerard Kerbourch
Top achievements
Rank 1
Gerard Kerbourch asked on 12 Nov 2009, 10:50 AM

Hi,

How to detect header column click event ?

I  couldn't find the appropriate event in grid properties...

In order to do that, I've put a label in each column header, and handle MouseLeftButtonUp event.
But of course it is not a good solution.

Does someone have better solution/idea ?

Thanks

7 Answers, 1 is accepted

Sort by
0
Accepted
Pavel Pavlov
Telerik team
answered on 17 Nov 2009, 07:01 PM
Hi Gerard ,

You may use the following approach :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Telerik.Windows.Controls.GridView;
using Telerik.Windows.Controls;
  
namespace StarColumnProblem
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            this.AddHandler(GridViewHeaderCell.MouseLeftButtonDownEvent, new MouseButtonEventHandler(MouseDownOnHeaderCell), true);
        }
  
        private void MouseDownOnHeaderCell(object sender, MouseEventArgs args)
        {
            GridViewHeaderCell cellClicked = ((FrameworkElement)args.OriginalSource).ParentOfType<GridViewHeaderCell>();
  
            if (cellClicked == null)
                return;
  
            MessageBox.Show(cellClicked.Column.UniqueName);
        }
    }


Greetings,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Gerard Kerbourch
Top achievements
Rank 1
answered on 08 Jan 2010, 10:36 AM
I am late, but thank you for response, it's ok now.

I have another problem with the GridView.

I want to get the double click on a line, but when I click at least 2 times in a row, I get an error that I can not control.
The GridView is loaded by this method:
http://www.scottlogic.co.uk/blog/colin/2009/04/binding-a-silverlight-datagrid-to-dynamic-data-via-idictionary/

It seems that the problem just because I do not meet property 'path' in the binding. But I can't find a solution, except perhaps the one below, but I did not understand ... :
http://blog.bodurov.com/How-to-bind-Silverlight-DataGrid-from-IEnumerable-of-IDictionary

Thank you for your help

0
Accepted
Vlad
Telerik team
answered on 08 Jan 2010, 12:06 PM
Hi Gerard,

You can try my DataTable instead.

All the best,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Gerard Kerbourch
Top achievements
Rank 1
answered on 08 Jan 2010, 01:50 PM
Hi Vlad,

Thanks you for your help. It's very nice solution.

0
Gerard Kerbourch
Top achievements
Rank 1
answered on 08 Jan 2010, 03:16 PM
New question...

how to convert in vb.net this code (data.cs class) :
 foreach (var row in this.Rows)  
                {  
                    var item = Activator.CreateInstance(type);  
                    propertyInfos.ForEach(p => p.SetValue(item, row[p.Name], null));  
 
                    list.Add(item);  
                }  
 

thanks

0
Vlad
Telerik team
answered on 11 Jan 2010, 07:21 AM
Hello Gerard,

You can use our powerful converter to translate this:
http://converter.telerik.com/

Kind regards,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Gerard Kerbourch
Top achievements
Rank 1
answered on 11 Jan 2010, 04:53 PM
I already tried but it's not good, the results :
For Each row As var In Me.Rows  
    Dim item As var = Activator.CreateInstance(type)  
    propertyInfos.ForEach(Function(p As ) p.SetValue(item, row(p.Name), Nothing))  
 
    list.Add(item)  
Next 

Finally, I managed to translate. My translation simplified :
                    Dim p As System.Reflection.PropertyInfo  
                    For Each p In propertyInfos  
                        If row.ContainsKey(p.Name) Then 
                            p.SetValue(item, row(p.Name), Nothing)  
                        End If 
                    Next 

Thanks
Tags
GridView
Asked by
Gerard Kerbourch
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Gerard Kerbourch
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or