do you know how is it possible to wire drag& Drop with Richtextbox ?
According MS doc, https://docs.microsoft.com/en-us/dotnet ... l#see-also
its needed to add DragEnter and DragDrop event + set AllowDrop = True. However this does not work for me, even if i added DragOver event as well. It seems like the form does not detect events when added to code just like that
so at the beginning, i added allowdrop to the load
- $formDragDropFiles_Load = { $richtextbox1.AllowDrop = $true }

- $richTextBox1_DragDrop = [System.Windows.Forms.DragEventHandler]{
- #Event Argument: $_ = [System.Windows.Forms.DragEventArgs]
- #Process the dropped files
- $files = $_.Data.GetData([System.Windows.Forms.DataFormats]::FileDrop)
- if ($files)
- {
- foreach ($file in $files)
- { $richTextBox1.Text = Get-Content $file }
- }
- }
- $richTextBox1_DragOver = [System.Windows.Forms.DragEventHandler]{
- #Event Argument: $_ = [System.Windows.Forms.DragEventArgs]
- if ($_.Data.GetDataPresent([Windows.Forms.DataFormats]::FileDrop)){
- $_.Effect = 'Copy' }
- else{
- $_.Effect = 'None' }
- }
- $richTextBox1_DragEnter = [System.Windows.Forms.DragEventHandler]{
- if ($_.Data.GetDataPresent([windows.forms.dataformats]::Text)){
- $_.Effect = 'Copy' }
- else{
- $_.Effect = 'None' }
- }