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.
Unfortunately, activation email could not send to your email. Please try again.

Highlight individual cell in a Windows Form grid

Thread ID:

Created:

Updated:

Platform:

Replies:

51771 Nov 14,2006 01:00 AM Nov 21,2006 06:35 AM Windows Forms 4
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On November 14, 2006 01:00 AM

Hi,

I would like to highlight (border and back color of) an individual cell in a Windows form grid.

Typical opearations are:
1. Right click on a cell and select an option (of some predefined options) and that should hightlight the cell

2. Search operation- search through the grid cells, when a match is found, hightlight that cell.

Do you have any sample or a explaining way for this type of operation?

I am using Syncfusion 4.2.0.37

Thanks,
Dheeraj

Administrator [Syncfusion]
Replied On November 14, 2006 02:06 AM

Hi Dheeraj,

Issue 1: highlight the current cell

If you want to highlight the current cell, you can handle the PrepareViewSyleInfo event and set the style for the currentcell. Here is a code snippet,

private void gridControl1_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
{
GridControl grid = sender as GridControl;
GridCurrentCell cc = grid.CurrentCell;
if( cc.RowIndex == e.RowIndex && e.ColIndex == cc.ColIndex)
{
e.Style.BackColor = grid.AlphaBlendSelectionColor;
e.Style.Borders.All = new GridBorder(GridBorderStyle.Solid);
}
}

Issue 2:

Please refer to the below forum thread for find functionality in a Grid.
http://www.syncfusion.com/support/Forums/message.aspx?MessageID=45839

Best Regards,
Haneef

Sandeep
Replied On November 17, 2006 07:29 AM

Hi Haneef,
It works very well for the current cell. But now we want it in such a way that I will choose any cell programmatically (like after searching the cell by any calculation) and then highlight the cell. I tried with your logic but it won't work. If I deactivate the program and again come to that form then I can see it is highlighted. How I can highlight it.

Following steps I want to do.
1. I will click one button.
2. Button will give me rowindex and colindex after some process.
3 I will highlight that cell of colindex and rowindex.
(I tried this with your logic of using previewstyleinfo event. but it is not hightlighting , only I can see it highlighted if I go to any other form and come back to the form)

Thanks,
Sandeep

Sandeep
Replied On November 21, 2006 06:13 AM

Hi Haneef,

Please provide me the solution for the above query. Its urjent.

Thanks,
Sandeep

Administrator [Syncfusion]
Replied On November 21, 2006 06:35 AM

Hi Sandeep,

Our apologies for the delay in response.

Use the Model.Selections property to manages selected ranges in the grid. It allows you to add and remove selections, determines selection state of a specific cell.

//highlight the row
this.grid1.Model.Selections.Add(GridRangeInfo.Row(RowIndex));
//highlight the cell
this.grid1.Model.Selections.Add(GridRangeInfo.Cell(RowIndex,ColIndex);
//highlight the cell
this.grid1.Model.Selections.Add(GridRangeInfo.Col(CoIIndex));

Best Regards,
Haneef

CONFIRMATION

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.

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.

;