We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Overriding Grid Cell Behaviour

Thread ID:





51058 Oct 26,2006 04:16 PM UTC Oct 27,2006 10:36 AM UTC WinForms 2
Tags: GridControl
David Hook
Asked On October 26, 2006 04:16 PM UTC


I have a three questions regarding overriding default grid behaviour.

My grid will contain static data comprising of an image, with cells being clickable (left click action, right click as context menus) to ultimately fire events back to the main app.

Q1. How do I collect click events on header / data cells to be able to display context menus?

Q2. I am looking to override the default behaviour of the grid when either the column or row headers are clicked upon. The Default behaviour is to highlight the column or row data, respectively, who's header has been clicked on. Please see attachment. How do I 'switch off' this behaviour?

Q3. I am also looking to override the 'border' that appears around a cell that has been selected. Probably by highlighting the cell in a different background colour, for instance, or having the 'border' in red instead of black. What would be the best way of achieving this?

Best Regards,



Administrator [Syncfusion]
Replied On October 27, 2006 06:47 AM UTC

Hi David,

Regarding the Q1: collect the cell click

To collect the mouse click for the header cell, you need to handle the MouseDown event of the grid. Below is a code snippet.

private void grid_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
Point pt = new Point(e.X,e.Y);
int row,col;
this.grid.PointToRowCol(pt,out row, out col);
Console.WriteLine(row +":::"+ col);

Regarding the Q2:

There is a property that controls this behavior of selecting the cells in a grid. Try the below code

this.grid.Model.Options.AllowSelection = GridSelectionFlags.Any ^ GridSelectionFlags.Column ^ GridSelectionFlags.Row;

This should prevent the column and row selection when clicked on the column header/row header.

Regarding the Q3: change the CurrentCellBorder behavior

You can use the ShowCurrentCellBorderBehavior property to show/hide the black border in a grid. If you want to format the currentcell, you need to handle the PrepareviewStyleInfo event.

this.grid.Model.Options.ShowCurrentCellBorderBehavior = GridShowCurrentCellBorder.HideAlways;

//PrepareViewStyleInfo event.
GridCurrentCell cc = this.Grid.CurrentCell
if(e.RowIndex == cc.RowIndex && e.ColIndex == cc.ColIndex)
e.Style.Border.All = new GridBorder(GridBorderStyle.Solid,Color.Red);

Please let me know if this does not handle things for you,

Best Regards,

David Hook
Replied On October 27, 2006 10:36 AM UTC

Hi Haneef

Perfect! Thanks very much for your help.

Best Regards,



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon