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

ExcelLikeCurrentCell & ExcelLikeSelectionFrame & grid.selections.count

I found on ur forum once that if u wanted to tell if u have more then one cell selected that u could use the grid.selections.count property for this. I only want the user to be able to go to another form by either double clicking the cell or a button but only if they have JUST ONE cell selected. So in the past I checked the grid.selections.count and if only one cell was selected it would return a zero. if you selected say 2 cells in one range it would return a one and i would know they had some sort of a range. if they selected 2 cells not in a range it would return a 2. so i figured out as long as it was zero there was only one cell. so this worked fine until we decided to turn on the ExcelLikeCurrentCell & ExcelLikeSelectionFrame. When that is on and when u selected ONE cell the selections count is now one? So this is where I am confused. Should it of always been one? Was this wrong and is now corrected? The big one to me is why is this different if these 2 properties are set to true or false? Maybe there is another way I can check for just one cell being checked but this was working great but now after turning those to properties to true it doesnt act the same?? Again now if i select 2 cells in a range with those properties set to true it returns 1 which i would assume is is correct but again why is it diff when these are set to false. I think there is some sort of a bug here and also think now I am going about trying to figure if more then one cell, range or not, has been selected..I have attached a sample. Select one cell one grid and push its button and look at the text box which is the count and do the same for the other grid. Thanx Phil selections.count_9396.zip

5 Replies

AD Administrator Syncfusion Team April 27, 2004 03:10 PM UTC

Hi Phil, This is by design. If you have ExcelLikeCurrentCell & ExcelLikeSelectionFrame set to true, the grid will consider the current cell to be selected. If you want the consistent behavior like the ExcelLikeCurrentCell is set to false, you can check whether the selection has only the currentcell and can decrement the count by 1 to handle this case. Here is some code snippet. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click TextBox1.Text = (GridControl1.Selections.Count).ToString() If (GridControl1.Selections.Count = 1) Then Dim range As GridRangeInfo = New GridRangeInfo range = GridRangeInfo.Cell(Me.GridControl1.CurrentCell.RowIndex, Me.GridControl1.CurrentCell.ColIndex) If (Me.GridControl1.Selections.Ranges.ActiveRange.Equals(range)) Then TextBox1.Text = (GridControl1.Selections.Count - 1).ToString() End If End If End Sub Attached is the sample. Thanks. Jay N selections.count_2975.zip


PB Philip Bishop April 27, 2004 03:35 PM UTC

am i doing this right in the first place??is this the best way to tell that ONLY 1 cell is selected..Not one range, just ONE CELL . I just want to know that there is eithe r ONE cell selected or more then one cells selected, ranges or not


AD Administrator Syncfusion Team April 27, 2004 11:09 PM UTC

Hi Phil, The currentcell will not be a part of the selection when the ExcelLikecurrentcell is set to false. The selectioncount will be zero in this so you can rely on this approach. Regards, Jay N


PB Philip Bishop April 28, 2004 10:31 AM UTC

i think i''m not explaining myself well enough. i want the excel properties set to TRUE. so i asked is this the only way to tell if one cell is selected like u gave me in that sample or is there an easier way


AD Administrator Syncfusion Team April 28, 2004 02:53 PM UTC

Hi Phil, This is the way to tell whether one cell is selected. The code just checks whether the current cell is in the selected range. Regards, Jay N

Loader.
Live Chat Icon For mobile
Up arrow icon