Menu

Trap Header Click Event

Help
Anonymous
2007-03-03
2013-04-23
  • Anonymous

    Anonymous - 2007-03-03

    Hopefully this is a simple question and I'm just missing something obvious.

    How do I setup my own event for when the user clicks on a column header?

    Thanks!

     
    • Davide Icardi

      Davide Icardi - 2007-03-03

      Hi,

      The column header is like any other cells so you can use a Controller class.

      Try to look at this link for more informations:
      http://www.devage.com/Wiki/ViewArticle.aspx?name=sourcegrid&version=0#SourceGrid_Basic_Concepts_Controller

      Here a quick example:

      class ClickController : SourceGrid.Cells.Controllers.ControllerBase
      {
          public override void OnClick(SourceGrid.CellContext sender, EventArgs e)
          {
              base.OnClick(sender, e);

              object val = sender.Cell.Model.ValueModel.GetValue(sender);
              if (val != null)
                  MessageBox.Show(sender.Grid, val.ToString());
          }
      }

      SourceGrid.Cells.ColumnHeader header = (SourceGrid.Cells.ColumnHeader)grid1[0, 0];
      header.AddController(new ClickController());

      Davide

       
      • Anonymous

        Anonymous - 2007-03-04

        Awesome!

        That was exactly what I needed.

        Thanks!

        Joe,

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.