Hello,
I use base.Model.Selections.Ranges.ActiveRange to get the active selection in the grid. The range contains cells of one column only. I would like to extend the range towards the top or bottom of the column, as long as the cell contains valid data. I am able to navigate in both directions, away from my predefined range, and I can detect if the values found are valid. With every valid cell found, I would like to extend my range, so it grows towards the top and bottom until some invalid data is found.
I would also like to distribute the columns with evenly widths for the given grid canvas.
How could I achieve this? Any help is very much appreciated.
Best regards, Frank
AD
Administrator
Syncfusion Team
June 28, 2006 06:01 PM UTC
Hi Frank,
To extend the current selection in a grid, you need to use the Selections.Add method. Here is a code snippet.
//It selects the consecutive cells having the "Valid" text in the column 1 of the grid
for(int i = 1 ;i <= this.gridControl1.RowCount;i++)
{
if( this.gridControl1.Model[i,1].Text == "Valid" )
this.gridControl1.Model.Selections.Add(GridRangeInfo.Cell(i,1));
else
break;
}
Let me know if this helps.
Best Regards,
Haneef
FG
Frank Gebhardt
June 29, 2006 06:17 AM UTC
Hi Haneef,
Selection.Add will add a new GridRangeInfo to my GridInfoList, so I will end up with a big array of GridRangeInfo objects, one for each cell that is analysed.
Is it possible to merge all these GridRangeInfo objects in to one? Instead of 2 GridRangeInfo objects, e.g. gr1 (R1C1 to R5C1) and gr2 (R6C1 to R10C1) I would like to obtain one grRes (R1C1 to R10C1).
Thanks for your help!
Best regards, Frank
>Hi Frank,
>
>To extend the current selection in a grid, you need to use the Selections.Add method. Here is a code snippet.
>
>//It selects the consecutive cells having the "Valid" text in the column 1 of the grid
>for(int i = 1 ;i <= this.gridControl1.RowCount;i++)
>{
> if( this.gridControl1.Model[i,1].Text == "Valid" )
> this.gridControl1.Model.Selections.Add(GridRangeInfo.Cell(i,1));
> else
> break;
>}
>
>Let me know if this helps.
>Best Regards,
>Haneef
AD
Administrator
Syncfusion Team
June 29, 2006 06:42 PM UTC
Hi Frank,
The CoveredCells Browser sample shows you how to make a range of cells behave as a single large cell. You can embed bitmaps or other controls into a covered cell. The appearance of a covered cell is determined by the GridStyleInfo object on the top-left cell in the covered range. In the code, you will notice that you can set the border for the covered cell by just setting the border of the top-left cell of the covered range. In general, the cell style properties of the top-left cell will determine the properties for the covered cell.
Here is a path.
\Syncfusion\Essential Studio\4.2.0.37\windows\Grid.Windows\Samples\Quick Start\CoveredCells\
Let me know if this helps.
Best Regards,
Haneef
FG
Frank Gebhardt
June 30, 2006 07:59 AM UTC
Hi Haneef,
I dont'' want to cover the cells. The cells should remain as they are. I only want to cover a range of cells, so a range can be extended by one or more single cell. Let''s assume that the user visually selected three cells. I n my code, I cache the selection in a GridRangeInfo, that covers these three cells (e.g. r2c1 to r4c1). Now, I want to be able to programmatically extend my internally cached GridRangeInfo by e.g. another 5 cells, so my GridRangeInfo now spans from r2c1 to r9c1. I do not find ways to modify an existing GridRangeInfo.
Best regards, Frank
AD
Administrator
Syncfusion Team
June 30, 2006 07:07 PM UTC
Hi Frank,
Sorry for the inconvenience caused.
Try this code to modify the existing GridRangeInfo object.
GridRangeInfo info = GridRangeInfo.Cells(2,1,4,1) ;
Console.WriteLine("Old Range ==> " + info.Info);
info = info.UnionRange(GridRangeInfo.Cells(5,1,9,1 ));
Console.WriteLine("New Range ==> " + info.Info);
Let me know if this helps.
Best Regards,
Haneef
FG
Frank Gebhardt
July 3, 2006 07:35 AM UTC
Hi Haneef!
Thanks a lot for your patience! UnionRange solved my problem. I knew that the grid would support a feature like this. Somehow I was too blind to find that method.
Great support!
Regards, Frank