Hello Lars,
In order to do this, I believe it will be useful for you to know that there exists a bool, CopyFieldLabelsToClipboard property on the XamDataGrid.FieldLayoutSettings. I would recommend that you throttle this property and set it to true or false depending on the number of cells that are selected in your XamDataGrid.
I would also recommend handling the XamDataGrid.SelectedItems.Cells.CollectionChanged event in this case. This will allow you to catch the cells as they are selected in the grid, and view that collection. If more than a single cell is selected at a particular time, I would set the XamDataGrid.FieldLayoutSettings.CopyFieldLabelsToClipboard property to true. Otherwise, you can set it back to false to prevent the Field labels from being copied to the clipboard.
I hope this helps. Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate Developer
Hi Andrew,
I followed your line of thought.
My code works as far as I have tested:
Private Sub DgrPrinters_SelectedItemsChanged(sender As Object, e As SelectedItemsChangedEventArgs) Handles DgrPrinters.SelectedItemsChanged ' Omit labels when only one cell is selected. Works with v17.1 ' When whole rows are selected via clicking the "little row arrow to the left" the "SelectedItems.Cells.Count" surprisingly returns 0 DgrPrinters.FieldLayoutSettings.CopyFieldLabelsToClipboard = (DirectCast(sender, XamDataGrid).SelectedItems.Cells.Count <> 1) 'Debug.WriteLine(DirectCast(sender, XamDataGrid).SelectedItems.Cells.Count.ToString)End Sub
Can You say if there is a more prefered way of doing this than the way I did it ?
Regards,
Lars
The way that you are currently handling things looks to be correct, and I can offer an explanation to the behavior that you are seeing when clicking the "little row arrow to the left."
That little arrow to the left is an element called the RecordSelector. Looking at the SelectedItems collection of the XamDataGrid, you may have noticed that there are actually a few sub-collections - Cells, Records, and Fields. When you click the RecordSelector element, you are not really selecting the cells of that particular record, but rather, the entire record itself, and so it will go into the SelectedItems.Records collection.
I would recommend checking your SelectedItems.Records collection in conjunction with the SelectedItems.Cells collection to determine whether or not to pull the labels into the "copy" clipboard operation.
Please let me know if you have any other questions or concerns on this matter.