This is a migrated thread and some comments may be shown as answers.

[Solved] Selection Changed

1 Answer 147 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Scott Rakestraw
Top achievements
Rank 1
Scott Rakestraw asked on 25 Sep 2009, 04:32 PM
I am using the new gridviewselect column and it is working great.  My grid is set up to be readonly and the user will select rows.  After selecting and pressing an edit button the grid will hide and a second editable grid will be displayed with the records selected in the first grid.  This is working fine, but what I want is if the user clicks a row it just adds that record to the selected items collection.  I have the following.

    Private Sub myGrid_SelectionChanged(ByVal sender As Object, ByVal e As Telerik.Windows.Controls.SelectionChangeEventArgs) Handles myGrid.SelectionChanged 
 
        If e.AddedItems.Count <> 0 Then 
            For Each item As Object In e.RemovedItems 
                myGrid.SelectedItems.Add(item) 
            Next 
        End If 
 
    End Sub 

When I turn the debugger on this seems to work fine, but if I do not have a break point in this function when I click a row not clicking the gridviewselect column it will not add back all of the removed items.

1 Answer, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 29 Sep 2009, 12:38 PM
Hello Scott Rakestraw,

Several people have requested to add such feature to the grid and we have decided to implement it. Such feature allows users to select and deselect items by just clicking on them using a mouse - this is what Microsoft calls Multiple Selection. This feature should be introduced with our Latest Internal Build this Friday.

In the meantime you could try the following workaround:

Private selectionIsChanging As Boolean 
 
Private Sub RadGridView_SelectionChanged(sender As Object, e As SelectionChangeEventArgs)  
    If selectionIsChanging Then 
        Return 
    End If 
 
    selectionIsChanging = True 
 
    For Each item As Object In e.RemovedItems  
        If Keyboard.Modifiers <> ModifierKeys.Control Then 
            Me.playersGrid.SelectedItems.Add(item)  
        End If 
    Next 
 
    selectionIsChanging = False 
End Sub 

There is only one problem with that code - while the user can select items by just clicking on them he is required to hold down the Control key to unselect an item.

Hope this helps.

Regards,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Scott Rakestraw
Top achievements
Rank 1
Answers by
Milan
Telerik team
Share this question
or