Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy Paste not supported from selected records in gridview output window #30

Open
alienBear opened this issue Aug 19, 2019 · 3 comments
Open

Comments

@alienBear
Copy link

@alienBear alienBear commented Aug 19, 2019

In original out-GridView output window, records could be selected and then copied to the clipboard to paste into emails or spreadsheets. This no longer appears to be possible under the current implementation. This issue is similar to issue #23 .

WorkAround Available: I found I could accomplish what I needed in the short term with the following, but the output window is dismissed, so multiple subsequent selections are not possible from the same output window.

... | Out-GridView -PassThru | convertTo-HTML | clip.exe

@corbob
Copy link
Contributor

@corbob corbob commented Oct 2, 2019

🤔 I thought maybe this would be easy, but apparently it isn't...

https://github.com/PowerShell/GraphicalTools/blob/master/src/OutGridView.Gui/Views/DataGridView.xaml#L23 would seem to indicate there's a copy mode. Setting it to ExcludeHeader as per the docs results in an exception when you try to copy:

Unhandled exception. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.ArgumentException: The value "15" is not of type "OutGridView.Models.IValue" and cannot be used in this generic collection. (Parameter 'value')
   at System.Collections.Generic.Dictionary`2.System.Collections.IDictionary.set_Item(Object key, Object value)
   at Avalonia.Markup.Parsers.Nodes.StringIndexerNode.SetTargetValueCore(Object value, BindingPriority priority)           at Avalonia.Data.Core.BindingExpression.OnNext(Object value)
   at Avalonia.Reactive.AvaloniaPropertyObservable`1.Subscribed(IObserver`1 observer, Boolean first)
   at Avalonia.Reactive.LightweightObservableBase`1.Subscribe(IObserver`1 observer)
   at Avalonia.Data.BindingOperations.Apply(IAvaloniaObject target, AvaloniaProperty property, InstancedBinding binding, Object anchor)
   at Avalonia.AvaloniaObjectExtensions.Bind(IAvaloniaObject target, AvaloniaProperty property, IBinding binding, Object anchor)
   at Avalonia.Controls.DataGridColumn.GetCellValue(Object item, IBinding binding)
   at Avalonia.Controls.DataGrid.ProcessCopyKey(InputModifiers modifiers)
   at Avalonia.Controls.DataGrid.ProcessDataGridKey(KeyEventArgs e)
   at Avalonia.Controls.DataGrid.DataGrid_KeyDown(Object sender, KeyEventArgs e)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at Avalonia.Interactivity.Interactive.RaiseEventImpl(RoutedEventArgs e)
   at Avalonia.Interactivity.Interactive.BubbleEvent(RoutedEventArgs e)
   at Avalonia.Interactivity.Interactive.RaiseEvent(RoutedEventArgs e)
   at Avalonia.Input.KeyboardDevice.ProcessRawEvent(RawInputEventArgs e)
   at Avalonia.Input.InputManager.ProcessInput(RawInputEventArgs e)
   at Avalonia.Win32.WindowImpl.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam)
   at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg)
   at Avalonia.Win32.Win32Platform.RunLoop(CancellationToken cancellationToken)
   at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken)
   at Avalonia.Application.Run(CancellationToken token)
   at OutGridView.Application.AvaloniaAppRunner.AppMain(Application app) in C:\code\GraphicalTools\src\OutGridView.Gui\AvaloniaAppRunner.cs:line 62
   at OutGridView.Application.AvaloniaAppRunner.RunApp(ApplicationData applicationData) in C:\code\GraphicalTools\src\OutGridView.Gui\AvaloniaAppRunner.cs:line 44
   at OutGridView.Application.Program.Main(String[] args) in C:\code\GraphicalTools\src\OutGridView.Gui\Program.cs:line 32

Noting that the value changes based on which line you try to copy, we might need to add a handler or something for it.

@TylerLeonhardt
Copy link
Member

@TylerLeonhardt TylerLeonhardt commented Oct 2, 2019

@corbob do you think we could get an issue going on Avalonia for this?

@corbob
Copy link
Contributor

@corbob corbob commented Oct 3, 2019

@TylerLeonhardt I don't think an issue is happening with Avalonia, everything that I'm seeing indicates that even with WPF you need to create your own Copy handler, I just can't seem to get it to work (hence the question in discord about attaching a debugger). I'll spend some time on Monday trying to get a copy handler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.