radGridView1_CustomSorting event not firing

2 posts, 1 answers
  1. Dave
    Dave avatar
    5 posts
    Member since:
    Apr 2011

    Posted 11 Oct 2011 Link to this post

    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? 

  2. Answer
    Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 12 Oct 2011 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top