Home Forums WPF controls Xceed DataGrid for WPF Select multiple rows with CTRL+click not working

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • HanzieV
    Participant
    Post count: 13
    #43625 |

    Hi all,

    I’ve got this strange problem. When trying to select multiple random rows in my grid by using CTRL +(left) click, nothing happens. Selecting multiple sequential rows by using SHIFT + (left) click works fine. I already tried setting the Selection mode of the grid to Extended but that did not work. Any thoughts anyone ?

    Best regards,
    Hans

    Fawzi [Xceed]
    Member
    Post count: 722

    Hi,

    Unfortunately, I was not able to reproduce the issue by using our “Selection” sample project. By using CTRL +(left) click, I was able to select multiple random rows. The referred sample should be located, by default, at the following path on your machine:

    C:\Xceed Samples\Xceed DataGrid for WPF Professional Edition v5.8\CSharp\Selection

    If you are experiencing a different behavior, could you send me a simple stand alone sample project which reproduces the issue so that I could have a closer look. You may send your project to: support@xceed.com

    HanzieV
    Participant
    Post count: 13

    Hi,

    thanks for your reply !

    I have found the cause of the problem: the binding of the SelectedItem. After deleting this binding I can multi select random rows using CTRL+click.

    Here’s the defenition of my grid in XAML:

    <datagridtoolkit:DataGridControl x:Name=”TransportJobDataGrid” controls:FocusExtension.IsFocused=”{Binding IsTransportJobDataGridFocused}” ItemsSource=”{Binding TransportJobView}” SelectedItem=”{Binding CurrentTransportJob}” SynchronizeCurrent=”True” AutoCreateColumns=”False” TabIndex=”0″ ReadOnly=”True” ScrollViewer.CanContentScroll=”False” AutoScrollCurrentItem=”All” IsRefreshCommandEnabled=”False” MouseDoubleClick=”TransportJobDataGrid_MouseDoubleClick” SelectionMode=”Extended”>

    And here is the ‘CurrentTransportJob’:

    public TransportJobModel CurrentTransportJob
    {
    get { return _currentTransportJob; }
    set
    {
    if (_currentTransportJob != value)
    {
    _currentTransportJob = value;
    NotifyPropertyChanged(“CurrentTransportJob”);
    }
    }
    }

    My TransportJobModel class implements the INotifyPropertyChanged interface.

    I tried to reproduce the problem in a simple project, without succes, so I think the problem is related to my TransportJobModel class …

    Best regards,
    Hans

    HanzieV
    Participant
    Post count: 13

    Hi,

    after some more research I found that the problem was caused by following piece of code:

    private void TransportJobView_CurrentChanged(object sender, EventArgs e)
    {
    CurrentTransportJob = TransportJobView.CurrentItem as TransportJobModel;
    }

    Some explanation:
    I have a toolbar with a next (previous) button to scroll through the grid. The pointer is moved by executinting the ‘MoveCurrentToFirst(Last) on the view (ICollectionView) that is bound to the grids ItemSource (TransportJobView) and setting the CurrentTransportJob wit the above code. This works fine, except for the CTRL+click selection of rows. When putting the above code in comment, the random selection of rows works fine.

    To solve the problem I have changed the my CurrentTransportJob property to reflect the views CurrentItem:

    public TransportJobModel CurrentTransportJob
    {
    get
    {
    return TransportJobView.CurrentItem as TransportJobModel;
    }
    set { NotifyPropertyChanged(“CurrentTransportJob”); }
    }

    This moves the pointer in the grid to the next row, but the row is not ‘higlighted’. With highligthed I mean that, in my case, the selected row has a green background. When moving to another row with the keyboards arrows, the background of the selected row becomes green, but when moving with the toolbox button, it doesn’t. So now I need to solve this problem.

    I hope my explanation is understandable. Please do not hesitate to contact me for more information.

    Thanks !

    Best Regards,
    Hans

    Fawzi [Xceed]
    Member
    Post count: 722

    Hi Hans,

    Are you setting both the selected and current item property to that data item? Could you send me a sample project which rerproduces the issue so that I could have a closer look.

    HanzieV
    Participant
    Post count: 13

    Hi,

    I solved the problem with following code:

    public TransportJobModel CurrentTransportJob
    {
    get
    {
    return _currentTransportJob;
    }
    set
    {
    if (_currentTransportJob != value)
    {
    _currentTransportJob = value;
    NotifyPropertyChanged(“CurrentTransportJob”);
    }
    }
    }

    Best regards,
    Hans

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.