Set IsSelectable = "false" with SelectionMode = "MultiRange"

Posted by: mr.wlight on 30 July 2018, 6:18 pm EST

    • Post Options:
    • Link

    Posted 30 July 2018, 6:18 pm EST

    I have problem with SelectionMode = “MultiRange” and IsSelectable.

    My sample have two row, one row with IsSelectable = “false” and other is not.

    Then why when i set IsSelectable = “false” and this column still select.

  • Posted 31 July 2018, 4:53 pm EST

    Hello,

    Setting C1DataGrid’s SelectionMode property to MultiRange and trying to set IsSelectable to False for a column/row, the behavior at my end seems correct and does not change the CurrentCell. Are you confusing Mouse-hover color with Selected color. Please see below attached image.

    If you wish to do not show mouse hover color too then you may use PreviewMouseMove event as follows:

    private void _grid_PreviewMouseMove(object sender, MouseEventArgs e)
    {
        DataGridCell cell = _grid.GetCellFromPoint(e.GetPosition(_grid));
        if(cell!=null)
        {
            if (cell.Column.Index == 1)
            {
                _grid.MouseOverBrush = Brushes.Transparent;
            }
            else
            {
                _grid.MouseOverBrush = br;
            }
        }
    }
    
    ```If this is what you wanted, could you please elaborate more on this and share an image/video to illustrate your concern.
    
    Thanks,
    Ruchir
    
    [img]https://gccontent.blob.core.windows.net/forum-uploads/file-b1cc8819-bcc6-4040-9268-ceeca685dfb5.png[/img]
  • Posted 1 August 2018, 1:21 pm EST

    Hi, Ruchir

    I have issue with blank column ( column auto generate). I don’t want blank column selected. Because when blank column selected, Selection Column selected too. I try to can’t selected blank column. Can you help fix this issue ?

  • Posted 1 August 2018, 7:58 pm EST - Updated 4 October 2022, 12:15 am EST

    Hi,

    I am sorry but I am not able to replicate the issue at my end.

    AutoGenerating columns in C1DataGrid , not passing any data to one of the columns and setting its IsSelectable property to false, grid does not allow to select any cells of that column at my end.

    See attached video and refer the sample attached used to test the issue.

    So, I would like to ask you about the build version you are using and if you are using any build version older than 2018v2 then could you test the issue using the latest version which can be downloaded using: http://prerelease.componentone.com/dotnet40/c1wpflibrary/2018-t2/C1WPFBasicLibrary.4_4.0.20182.595.zip

    Thanks,

    Ruchir



    IsSelectable_WPF.zip

  • Posted 6 August 2018, 2:47 pm EST

    Of couse, I used lastest C1 version. I just ask you, when set one column IsSelectable = “false”, why this column still selected with behavior keep mouse and drag in cell. You can see my attached.

    I think ploblem is drag behavior.

  • Posted 6 August 2018, 4:58 pm EST

    Hi,

    It looks like your file did not attach properly. So, could you please re-try to attach the same so that I may understand the issue better.

    Thanks,

    Ruchir

  • Posted 6 August 2018, 6:18 pm EST

    Hi,

    Sorry Ruchir because i not read Images and ZIPs only

    That why i’m not attach anything.

    IsSelectedSample.zip

  • Posted 7 August 2018, 8:26 pm EST

    Hello,

    Thank you for sharing the video.

    However, when we tried to perform the same at our end, the behavior is different and the cells in the first column do not get selected. See attached image.

    I tested this with various machines and the behavior remains the same for all, like the one shown in video I shared with you earlier. So, could you share the environment details like OS version etc, which might help us to detect the source of the issue.

    Also, from the video it looks like you are only clicking the cells and after few clicks the cells in the first column [with IsSelectable=false] start getting selected. Or is there anything else that you are doing when the issue happens? If so, could you please share detailed steps to replicate the issue.

    However, if still we are not able to proceed further and able to replicate the issue, we would like to remote connect to your machine and check, if you are okay with it!

    Thanks,

    Ruchir

    IsSelectableFalse.zip

  • Posted 8 August 2018, 1:47 pm EST - Updated 4 October 2022, 12:15 am EST

    Ok, I describe again more clearly.

    In your sample please notice to “Not selectable column”.

    1. I just click any cell => everything is ok, cells not selected.
    2. I click + mouse move in cell => this cell is selected => problem here.

    I think it’s bug of C1. Please fix it!

  • Posted 8 August 2018, 4:47 pm EST

    Hi,

    Thank you for elaborating. I am able to see what you are pointing at.

    However, this is due to selecting a range (SelectionMode=MultiRange) and as soon as you click a cell and start dragging mouse within the same cell, grid starts adding it to the SelectionRange.

    To prevent this, you need to use SelectionDragStarted event and cancel as follows

    private void _grid_PreviewMouseDown(object sender, MouseButtonEventArgs e)
    {
        C1.WPF.DataGrid.DataGridCell cell = _grid.GetCellFromPoint(e.GetPosition(_grid));
        if (cell != null)
        {
            currentCell = cell;
            inBrush = currentCell.Presenter.Background;                
        }
    }
    private void _grid_SelectionDragStarted(object sender, C1.WPF.DataGrid.DataGridSelectionDragStartedEventArgs e)
    {
        if(_grid.Selection.SelectedCells.Count>0)
        {
            if(currentCell.Column.Header.ToString()== "Not Selectable")
            {
                e.Cancel = true;
            }
        }
    }
    ```Thanks,
    Ruchir
  • Posted 14 August 2018, 8:58 pm EST - Updated 4 October 2022, 12:15 am EST

    I was follow your solution,but i still selected “Not Selectable” cells.

  • Posted 16 August 2018, 1:24 am EST

    Hello,

    I am discussing the issue with the development team [ID:339379] and will update you once we have some solution/information for you.

    Thanks,

    Ruchir

  • Posted 20 August 2018, 3:11 pm EST

    Upon investigation, we found that there is indeed some issue with preventing selection for a column in C1DataGrid. Our development team is working to correct the same. However, it may take some time.

    Meanwhile, I would like to know whether are you in the initial stage of your application and would it be feasible for you to migrate to another grid control. I am asking this because disabling selection for a column works in C1FlexGrid, another grid control offering more flexibility than C1DataGrid. Please refer attached sample application for the same.

    Therefore, if you are starting off with your project, I would suggest you to try using C1FlexGrid instead or share your requirements so that we could suggest you a solution accordingly,

    Thanks,

    Ruchir

    FlexGridSelectionCancel.zip

  • Posted 26 August 2018, 7:17 pm EST

    Hi Richur,

    Thanks for response. My application was custom enough, i don’t wanna change to C1FlexGrid.

    I want to know how long your team can fix it?

  • Posted 27 August 2018, 9:20 pm EST

    Hi,

    I have forwarded your concern to the team and discussing with them as to by when can this issue be fixed in C1Datagrid.

    Thanks,

  • Posted 4 September 2018, 2:33 pm EST

    Hello,

    Attached is a sample implementing your requirement.

    Basically, SelectionChanging event can change DataGrid.SelectionRanges if we just change the items in AddedRanges. So we have added a method ‘SelectableRanges’ to check if this column\rows IsSelectable or not.

    Let me know if it satisfies your requirement/not.

    Thanks,

    Ruchir

    IsSelectableSample.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels