Welcome to the Xceed Community | Help
Community Search  
More Search Options

Highlighting the current cell

Sort Posts: Previous Next
  •  01-28-2009, 2:36 PM Post no. 28269

    Highlighting the current cell

    You can use the CurrentCellChanged event and change the background color of the current cell; however, if you are using a Vista style, you will need to also override the UIStyle for this to works, since when choosing a style like AERO, it automatically sets many properties.

    private void Form1_Load( object sender, EventArgs e )
        {
          gridControl1.CurrentCellChanged += new EventHandler( gridControl1_CurrentCellChanged );

          //For a Vista theme
          gridControl1.SelectionVisualStyle.OverrideUIStyle = true;
          gridControl1.SelectionVisualStyle.BackColor = Color.FromArgb( 40, gridControl1.SelectionBackColor );
        }

        private DataCell previousCell;

        void gridControl1_CurrentCellChanged( object sender, EventArgs e )
        {
          if( previousCell != null )
          {
            previousCell.BackColor = gridControl1.DataRowTemplate.BackColor;
          }
          if( gridControl1.CurrentCell.GetType() == typeof( DataCell ) )
          {
            gridControl1.CurrentCell.BackColor = Color.DeepPink;
          }
          previousCell = gridControl1.CurrentCell as DataCell;
        }

     

View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.