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. Image for the cookie policy date

Coverd Cell

I have few header cells (both in row and column) as covered cell. I need help to achieve the following. If a user click on one of the covered cell in column or row header I need to select all the column (based on covered cell) or all the rows (based on covered cell). Let me try putting an example: this.programGrid.Model.CoveredRanges.Add(GridRangeInfo.Cells(0,1,0,2)); this.programGrid.Model.CoveredRanges.Add(GridRangeInfo.Cells(0,5,0,7)); So if they click either on column 1 or 2 it should select both (1,2) columns. If they click one on the 5,6 & 7 column then it should select all three(5,6,7) columns. I think it should be doable but need little direction. Thanks

3 Replies

AD Administrator Syncfusion Team June 2, 2004 05:59 PM UTC

You can handle the SelectionsChanging event and adjust e.Range if the selection intersects a coveredcell. Here is a try at this.
private void gridControl1_SelectionChanging(object sender, GridSelectionChangingEventArgs e)
	if(!e.Range.IsEmpty && e.Range.IntersectsWith(GridRangeInfo.Row(0)))
		GridRangeInfo range = e.Range.IntersectRange(GridRangeInfo.Row(0));
		range = this.gridControl1.CoveredRanges.FindRange(0, range.Left);
			e.Range = GridRangeInfo.Cols(range.Left, range.Right);

VI Vivek June 2, 2004 07:01 PM UTC

Thanks. It is working except that it does not select “First” cell. If covered range is (0,5,0,7) then does not matter where I click (on column 5,6 & 7) it does not select cell[0,5]. I would appreciate your reply! Thanks

AD Administrator Syncfusion Team June 2, 2004 07:32 PM UTC

This is by design. When you select a range of cells, the current cell is not selected. If you do not want this behavior, you can handle CurrentCellActivating and cancel it if you are trying to activate a header cell.
private void gridControl1_CurrentCellActivating(object sender, GridCurrentCellActivatingEventArgs e)
	if(e.RowIndex == 0)
		e.Cancel = true;

Live Chat Icon For mobile
Up arrow icon