This question is locked. New answers and comments are not allowed.
Hello. I have a GridView with a column as a checkbox bound to the IsSelect property of the DataRow. For some reason, to click on the checkbox to select the row, I have to click twice. It seems to me that the first click is setting the focus on the cell clicked, then the second click actually checks the checkbox.
Ideally, I would like to get rid of the checkbox and be able to select multiple rows by just clickin on the rows, but without having to press the Control or Shift keys. Clicking each row would be like having the Ctrl key pressed. I tried implementing this by adding a function on the row mousedown event, however this would unselect the previous selected rows.
Does anyone have any suggestions? Here is part of my code:
Page.xaml
Page.xaml.cs:
Ideally, I would like to get rid of the checkbox and be able to select multiple rows by just clickin on the rows, but without having to press the Control or Shift keys. Clicking each row would be like having the Ctrl key pressed. I tried implementing this by adding a function on the row mousedown event, however this would unselect the previous selected rows.
Does anyone have any suggestions? Here is part of my code:
Page.xaml
| <telerikGridView:RadGridView Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" |
| x:Name="gridMultiSelect_accounts" ColumnsWidthMode="Auto" |
| Width="auto" Height="330" VerticalGridlinesBrush="Transparent" |
| UseAlternateRowStyle="True" AutoGenerateColumns="False" ShowGroupPanel="False" |
| MultipleSelect="True" Margin="5,5,5,5" > |
| <telerikGridView:RadGridView.Columns > |
| <telerikGridView:GridViewColumn HeaderText="Select"> |
| <telerikGridView:GridViewColumn.CellTemplate> |
| <DataTemplate> |
| <CheckBox HorizontalAlignment="Center" VerticalAlignment="Center" Loaded="CheckBox_Loaded"/> |
| </DataTemplate> |
| </telerikGridView:GridViewColumn.CellTemplate> |
| </telerikGridView:GridViewColumn> |
| <telerikGridView:GridViewDataColumn HeaderText="Phone" UniqueName="Value"/> |
| <telerikGridView:GridViewDataColumn HeaderText="Account Description" UniqueName="Description"/> |
| <telerikGridView:GridViewDataColumn HeaderText="Group" UniqueName="GroupName"/> |
| </telerikGridView:RadGridView.Columns> |
| </telerikGridView:RadGridView> |
Page.xaml.cs:
| private void Page_Loaded(object sender, RoutedEventArgs e) |
| { |
| var proxy = new PortalService.PortalDB_serviceClient(); |
| proxy.GetAccountValidValuesCompleted += new EventHandler<GetAccountValidValuesCompletedEventArgs>(proxy_GetAccountValidValuesCompleted); |
| proxy.GetAccountValidValuesAsync(_appID); |
| // Set up GridView group on GroupName column |
| RadGroupDescription groupDescription = new RadGroupDescription(); |
| groupDescription.PropertyName = "GroupName"; |
| gridMultiSelect_accounts.GroupDescriptions.Add(groupDescription); |
| gridMultiSelect_accounts.SelectionChanged += new EventHandler<SelectionChangeEventArgs>(gridMultiSelect_accounts_SelectionChanged); |
| gridMultiSelect_accounts.RowLoaded += new EventHandler<RowLoadedEventArgs>(gridMultiSelect_accounts_RowLoaded); |
| } |
| void gridMultiSelect_accounts_RowLoaded(object sender, RowLoadedEventArgs e) |
| { |
| e.Row.MouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(Row_MouseLeftButtonUp); |
| } |
| void Row_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e) |
| { |
| GridViewRowItem row = (GridViewRowItem)sender; |
| row.IsSelected = !row.IsSelected; |
| } |
| private IList<AccountValidValues> _AccountValidValues; |
| private IList<string> _AccountNames, _SortFields; |
| void proxy_GetAccountValidValuesCompleted(object sender, GetAccountValidValuesCompletedEventArgs e) |
| { |
| gridMultiSelect_accounts.Items.Clear(); |
| _AccountValidValues = e.Result; |
| gridMultiSelect_accounts.ItemsSource = _AccountValidValues; |
| } |