Home Forums WinForms controls Xceed Grid for WinForms Highlighting the current cell

Viewing 1 post (of 1 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #17825 |

    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;
        }

     

    Imported from legacy forums. Posted by Xceed admin (had 2509 views)

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.