Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
486
Disable selection for certain columns
posted

Hello,

I am using a XamGrid 14.1 with RowSelection set to multiple and CellClickAction set to SelectRow. Selection is working fine but I have some Template Columns containing controls that can be worked with, without using edit mode. Clicking those controls messes up the selection made which makes it unusable for my scenario.

Is it possible to disable selection for these columns so that the made Row Selection does not change when a user works with the control? If it is not possible to do this for certain columns, is it possible to avoid changing the selection on all columns aside from the RowSelector? I tried to change the CellClickAction but the only other possible choice is SelectCell which also changes my selection even though CellSelection is set to None.

I also tried to change the slection settings on the CellClicked event but this is triggered after the selection has already changed and the regular MouseLeftButtonDown event isn't triggered at all. So I am currently out of ideas - please give me some hints how I could change this behavior.

Thanks

  • 34510
    Offline posted

    Hello ruud7,

    Which platform are you working with?  I see that you have another post for this same issue in the Silverlight forum. http://ko.infragistics.com/community/forums/t/89420.aspx

    The reason the MouseLeftButtonDown event is not firing is because the grid is handling it before it gets to you.  If you are using WPF you could use the PreviewMouseLeftButtonDown event instead but this is not available in Silverlight.  Something you can do is handle the SelectedRowsCollectionChanged event and inside this event, figure out if the user clicked on your template and if they did, reset the selected rows to what they were previously.  This is fairly straight forward in WPF but in Silverlight its a little tricky because you don't have Mouse.GetPosition() nor do you have Mouse.LeftButton to determine if the user has left clicked when the selection changed.  You can find the mouse position using a MouseMove event and I think in most cases this should be enough because most selection changes occur during a mouse click anyway so you might not need to care about whether it was clicked or not.  In the cases where you change the selected rows in code you can detach the SelectedRowsCollectionChanged event, make the changes and then rehook the event.