Copy files to clipboard in C#

Consider using the Clipboard class. It features all the methods necessary for putting data on the Windows clipboard and to retrieve data from the Windows clipboard. StringCollection paths = new StringCollection(); paths.Add(“f:\\temp\\test.txt”); paths.Add(“f:\\temp\\test2.txt”); Clipboard.SetFileDropList(paths); The code above will put the files test.txt and test2.txt for copy on the Windows Clipboard. After executing the code you … Read more

How can I set the position of my datagrid scrollbar in my winforms app?

You don’t actually interact directly with the scrollbar, rather you set the FirstDisplayedScrollingRowIndex. So before it reloads, capture that index, once it’s reloaded, reset it to that index. EDIT: Good point in the comment. If you’re using a DataGridView then this will work. If you’re using the old DataGrid then the easiest way to do … Read more

How do I make a PictureBox use Nearest Neighbor resampling?

I needed this functionality also. I made a class that inherits PictureBox, overrides OnPaint and adds a property to allow the interpolation mode to be set: using System.Drawing.Drawing2D; using System.Windows.Forms; /// <summary> /// Inherits from PictureBox; adds Interpolation Mode Setting /// </summary> public class PictureBoxWithInterpolationMode : PictureBox { public InterpolationMode InterpolationMode { get; set; } … Read more