Hi,
We're using Infragics WPF v 13.2
We've got a requirement where our users wish to multiselect rows by clicking and dragging the mouse. My understanding is that we can achieve this by setting CellClickAction to SelectRecord and SelectionTypeRecord to ExtendedAutoDrag.
But now they want to be able to copy the content of a cell. How can we do this without having CellClickAction = SelectCell? This would break the record multiselection when dragging the mouse.
Can you please advise?
Regards.
Hello,
I am just checking if you require any further assistance on the matter.
Thank you for your replies. I have been looking into your questions and you can get values of the multiple selected values Using the PreviewMouseUp event of the XamDataGrid like e.g.:
CellValuePresenter cellPresenter;
…
private void xamDataGrid1_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
var grid = sender as XamDataGrid;
if (grid == null)
return;
}
cellPresenter = Infragistics.Windows.Utilities.GetAncestorFromType(e.OriginalSource as DependencyObject, typeof(CellValuePresenter), false) as CellValuePresenter;
private void xamDataGrid1_PreviewMouseUp(object sender, MouseButtonEventArgs e)
List<string> cellValues = new List<string>();
var selectedRecord = (sender as XamDataGrid).SelectedItems.Records;
foreach (var item in selectedRecord)
if (cellPresenter != null)
cellValues.Add((item as DataRecord).GetCellText(this.xamDataGrid1.FieldLayouts[0].Fields[cellPresenter.Field.Name]));
Let me know, if you need any further assistance on this matter.
I just found a workaround though I'm still interested in your solution just in case our users ask for that in the future. At the moment they're interested in just a single cell.
Would it be possible to select 4 cells as you said while dragging down the mouse and the rows at the same time and then be able to copy the content of the four cells to the clipboard?
Thanks.
Have found a workaround: use CellClickAction="SelectRecord" and SelectionTypeRecord="ExtendedAutoDrag"
Then have an attached behavior hooked up to the grid's PreviewMouseDown event. The event handler will set the cell to active.
private static void GridOnPreviewMouseDown(object sender_, MouseButtonEventArgs args_) { var grid = sender_ as XamDataGrid; if (grid == null) { return; } var cellPresenter = Infragistics.Windows.Utilities.GetAncestorFromType(args_.OriginalSource as DependencyObject, typeof(CellValuePresenter), false) as CellValuePresenter; if (cellPresenter != null) { cellPresenter.IsActive = true; } }
Hello Ribao80,
Thank you for your post!
I have been looking into your issue and I have some questions regarding the scenario you want to achieve. Do you want the cells to be copied after user selects the them? For example if the user clicks on the left mouse button and selects 4 cells, when he releases the mouse button those cells that are selected to be automatically copied.
Thank you for the provided information. Looking forward to hearing from you.