
Gary Robson
Top achievements
Rank 1
Gary Robson
asked on 14 Dec 2010, 05:50 PM
Hi,
I've got a winform gridview. I want to give the ability to select multiple rows when pressing the space bar.
I've looked through the doc's and forum but can't get a solution.
Many thanks,
Gary
I've got a winform gridview. I want to give the ability to select multiple rows when pressing the space bar.
I've looked through the doc's and forum but can't get a solution.
Dim iRow As Integer = PoolGrid.Rows.IndexOf(PoolGrid.CurrentRow)
If iKey = 2097184 Then 'SPACE
PoolGrid.Rows(iRow).IsSelected = True
PoolGrid.Rows(iRow).IsCurrent = True
PoolGrid.SelectedRows.Add(PoolGrid.CurrentRow)
PoolGrid.Update()
PoolGrid.CurrentRow.VisualElement.RowVisualState = Telerik.WinControls.UI.GridRowElement.RowVisualStates.Selected
End If
Many thanks,
Gary
If iKey = 2097184 Then 'SPACE
PoolGrid.Rows(iRow).IsSelected = True
PoolGrid.Rows(iRow).IsCurrent = True
PoolGrid.SelectedRows.Add(PoolGrid.CurrentRow)
PoolGrid.Update()
PoolGrid.CurrentRow.VisualElement.RowVisualState = Telerik.WinControls.UI.GridRowElement.RowVisualStates.Selected
End If
If iKey = 2097184 Then 'SPACE
PoolGrid.Rows(iRow).IsSelected = True
PoolGrid.Rows(iRow).IsCurrent = True
PoolGrid.SelectedRows.Add(PoolGrid.CurrentRow)
PoolGrid.Update()
PoolGrid.CurrentRow.VisualElement.RowVisualState = Telerik.WinControls.UI.GridRowElement.RowVisualStates.Selected
End If
If iKey = 2097184 Then 'SPACE
PoolGrid.Rows(iRow).IsSelected = True
PoolGrid.Rows(iRow).IsCurrent = True
PoolGrid.SelectedRows.Add(PoolGrid.CurrentRow)
PoolGrid.Update()
PoolGrid.CurrentRow.VisualElement.RowVisualState = Telerik.WinControls.UI.GridRowElement.RowVisualStates.Selected
End If
5 Answers, 1 is accepted
0

Richard Slade
Top achievements
Rank 2
answered on 14 Dec 2010, 09:38 PM
Hi Gary,
I take it that your radgridView is readonly. If not, then the spacebar will start a cell in editing mode.
Can you expand a bit more on what you want to do? E.g. When a user presses the space bar once, you want to select the current row, plus the next row up / down? And then continue as they press space to select another row?
If you can let me know I'll try and help.
All the best
Richard
I take it that your radgridView is readonly. If not, then the spacebar will start a cell in editing mode.
Can you expand a bit more on what you want to do? E.g. When a user presses the space bar once, you want to select the current row, plus the next row up / down? And then continue as they press space to select another row?
If you can let me know I'll try and help.
All the best
Richard
0

Gary Robson
Top achievements
Rank 1
answered on 15 Dec 2010, 10:07 AM
Thanks for the reply.
The user needs to select various rows. Currently they use the CTRL+Mouse click, but a couple of users have asked to use the space bar to make the selections. So, every time the space bar is hit the current row needs to be added to the selected rows (multi select is enabled).
The grid is read only.
Cheers,
Gary
The user needs to select various rows. Currently they use the CTRL+Mouse click, but a couple of users have asked to use the space bar to make the selections. So, every time the space bar is hit the current row needs to be added to the selected rows (multi select is enabled).
The grid is read only.
Cheers,
Gary
0
Accepted

Richard Slade
Top achievements
Rank 2
answered on 15 Dec 2010, 11:02 AM
Hi Gary,
I'm not sure if it will be possible to do that. The SelectedRows collection is read only so it can be kept in sync correctly with the RowsCollection. Besides, when a user uses the mouse click and ctrl, then are of course not using the keyboard to navigate other rows. this may be the closest I can think of currently which on space sends Ctrl and Down to seleect the next row down as well as the current row.
i'd also say that this is not generally a Windows-ish thing tio do (multiselect using space). The Windows standard for multiselect is, as you've said, then ctrl/click combination.
hope that helps
Richard
I'm not sure if it will be possible to do that. The SelectedRows collection is read only so it can be kept in sync correctly with the RowsCollection. Besides, when a user uses the mouse click and ctrl, then are of course not using the keyboard to navigate other rows. this may be the closest I can think of currently which on space sends Ctrl and Down to seleect the next row down as well as the current row.
i'd also say that this is not generally a Windows-ish thing tio do (multiselect using space). The Windows standard for multiselect is, as you've said, then ctrl/click combination.
Private
Sub
RadGridView1_KeyDown(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.Windows.Forms.KeyEventArgs)
Handles
RadGridView1.KeyDown
If
Me
.RadGridView1.CurrentRow IsNot
Nothing
Then
If
e.KeyCode = Keys.Space
Then
Me
.RadGridView1.CurrentRow.IsSelected =
True
SendKeys.Send(
"^{DOWN}"
)
End
If
End
If
End
Sub
hope that helps
Richard
0

Gary Robson
Top achievements
Rank 1
answered on 15 Dec 2010, 11:12 AM
Cheers,
Mechanical engineers aren't normal people hence this odd request of space bar select. ;)
Thanks for the code.
Gary
Mechanical engineers aren't normal people hence this odd request of space bar select. ;)
Thanks for the code.
Gary
0

Richard Slade
Top achievements
Rank 2
answered on 15 Dec 2010, 11:18 AM
Haha, Glad that helped
All the best
Richard
All the best
Richard