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

radGridView1_CustomSorting event not firing

1 Answer 37 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 1
Dave asked on 11 Oct 2011, 10:39 PM
Hey everyone,

Title Correction: radGridView1_CustomGrouping event not firing

I am trying to implement the following example I have found in the Telerik forums to get custom month sorting to work. (Link) I tried setting the CustomDataOperation on the column as the example indicates. When I did that, the Intellisense description stated that the CustomDataOperation property was deprcated and to use EnableCustomGrouping, EnableCustomSorting, etc on the GridView instead. 

I have set all of these properties to true, yet the radGridView1_CustomSorting event does not fire. 

Why? What else is needed? 

1 Answer, 1 is accepted

Sort by
0
Accepted
Emanuel Varga
Top achievements
Rank 1
answered on 12 Oct 2011, 07:28 AM
Hello Dave,

Please take a look at the following example:

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Telerik.WinControls.UI;
 
public partial class CustomEventsFiringForm : Form
{
    private RadGridView _radGridView;
    private RadTextBox _textBox;
 
    public CustomEventsFiringForm()
    {
        InitializeComponent();
        _radGridView = new RadGridView();
        _radGridView.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
        _radGridView.Dock = DockStyle.Fill;
        //_radGridView.ShowFilteringRow = true;
        _radGridView.EnableFiltering = true;
        _textBox = new RadTextBox();
        _textBox.ReadOnly = true;
        _textBox.Dock = DockStyle.Bottom;
        this.Controls.Add(_textBox);
        _textBox.Multiline = true;
        _textBox.ScrollBars = ScrollBars.Vertical;
        _textBox.Height = 100;
 
        this.Controls.Add(_radGridView);
 
        _radGridView.CustomSorting += new GridViewCustomSortingEventHandler(_radGridView_CustomSorting);
        _radGridView.EnableCustomSorting = true;
        _radGridView.CustomGrouping += new GridViewCustomGroupingEventHandler(_radGridView_CustomGrouping);
        _radGridView.EnableCustomGrouping = true;
        _radGridView.CustomFiltering += new GridViewCustomFilteringEventHandler(_radGridView_CustomFiltering);
        _radGridView.EnableCustomFiltering = true;
 
        _radGridView.DataSource = Person.GetPersonList(10);
    }
 
    private void _radGridView_CustomFiltering(object sender, GridViewCustomFilteringEventArgs e)
    {
        Write("CustomFiltering called!");
    }
 
    private void _radGridView_CustomGrouping(object sender, GridViewCustomGroupingEventArgs e)
    {
        Write("CustomGrouping called!");
    }
 
    private void _radGridView_CustomSorting(object sender, GridViewCustomSortingEventArgs e)
    {
        Write("CustomSorting called!");
    }
 
    private void Write(string text)
    {
        _textBox.Text = DateTime.Now.ToShortTimeString() + text + Environment.NewLine + _textBox.Text;
    }
}
 
public class Person
{
    public int Id { get; set; }
 
    public string Name { get; set; }
 
    public Person()
    {
    }
 
    public Person(int id, string name)
    {
        Id = id;
        Name = name;
    }
 
    public static IEnumerable<Person> GetPersonList(int noItems)
    {
        for (int i = 0; i < 100; i++)
        {
            yield return new Person
            {
                Id = i,
                Name = "Person " + i.ToString()
            };
        }
    }
}

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

Best Regards,
Emanuel Varga

Telerik WinForms MVP
Tags
GridView
Asked by
Dave
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Share this question
or