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

Borders for a cell range

Concerning I have made a selection of some cells. Now I want to change the border for the whole selection (not for every cell in the selection but for the whole). Now I have the following code which doesn''t work: GridRangeInfoList aS = gridControl1.Model.SelectedRanges; GridRangeInfo rI = aS.ActiveRange; GridStyleInfo style = new GridStyleInfo(); style.Borders.All = new GridBorder(GridBorderStyle.Solid); gridControl1.ChangeCells(rI, style); So now i get every cell in my range selection with borders around. But i want a border around the whole selection - what can I do?

5 Replies

AD Administrator Syncfusion Team July 14, 2005 04:32 AM

First thing to check would be setting grid.ExcelLikeSelectionFrame = true to see if that gives you what you want. If not, you could divide the activerange up into 4 ranges, the top cells, the left cells, the bottom cells, and then the right cells. On these four ranges, you could use code like you have above to set the proper border on each range. So, on the left range, you would set Borders.Left instead of Borders.All, and do this for each of the four ranges. You could also look at the custom borders sample as that shows another way, you can handle custom borders. \Windows\Grid.Windows\Samples\In Depth\CustomBorders


FG Franz Gsell July 14, 2005 06:10 AM

So you mean I have to put the line: grid.ExcelLikeSelectionFrame = true on top of my code or do i have to select the rows in another way? >First thing to check would be setting grid.ExcelLikeSelectionFrame = true to see if that gives you what you want. > >If not, you could divide the activerange up into 4 ranges, the top cells, the left cells, the bottom cells, and then the right cells. On these four ranges, you could use code like you have above to set the proper border on each range. So, on the left range, you would set Borders.Left instead of Borders.All, and do this for each of the four ranges. > >You could also look at the custom borders sample as that shows another way, you can handle custom borders. \Windows\Grid.Windows\Samples\In Depth\CustomBorders


AD Administrator Syncfusion Team July 14, 2005 07:09 AM

You can set this property at design time or in form.load.
private void Form1_Load(object sender, System.EventArgs e)
{
	this.gridControl1.ExcelLikeSelectionFrame = true;
}
If you do this. the grid will draw a bold frame around the selection as your user selects a range of cells.


FG Franz Gsell July 14, 2005 07:14 AM

Ok, thank you very much, but this option doesn''t even take the effect i want. The border of the selected range is still set for every cell instead of the whole selected range (after setting the border for the range). So I think I have to implement your second suggestion to set the borders for every side seperately. Or is there another way? Kind regards Franz PS: The support is great - this makes a really good product :-))


AD Administrator Syncfusion Team July 14, 2005 07:56 AM

If you want to turn off the borders inside, then you would have to do it cell by cell. One way would be to loop through all the cells (not only the Left, Right, Top and Bottom), but also the interior cells and explicitly turn off the borders that you do not see. But another way would be to handle this dynamically using QueryCellInfo to provide the proper borders for each cell. You would also have to use SlectionsChanged to make sure the selected area is redrawn so the proper borders are seen. Here is a little sample. http://www.syncfusion.com/Support/user/uploads/GC_ExcelLikeSelectionFrame_e15b54f8.zip

Loader.
Live Chat Icon For mobile
Up arrow icon