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.
Syncfusion Feedback

Databound Grid: Increase selection programmatically

Thread ID:

Created:

Updated:

Platform:

Replies:

45782 Jun 28,2006 01:24 PM Jul 3,2006 03:35 AM Windows Forms 6
loading
Tags: GridControl
Frank Gebhardt
Asked On June 28, 2006 01:24 PM

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

Administrator [Syncfusion]
Replied On June 28, 2006 02:01 PM

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

Frank Gebhardt
Replied On June 29, 2006 02:17 AM

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

Administrator [Syncfusion]
Replied On June 29, 2006 02:42 PM

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

Frank Gebhardt
Replied On June 30, 2006 03:59 AM

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

Administrator [Syncfusion]
Replied On June 30, 2006 03:07 PM

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

Frank Gebhardt
Replied On July 3, 2006 03:35 AM

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

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.

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

;