How can I drag and drop TabPages between TabControls?

The following code snippet shows how you can drag a TabPage from TabControl1 and drop it into TabControl2 (whose AllowDrop property must be set to True): [C#] Source TabControl private void tabControl1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == MouseButtons.Left) { this.tabControl1.DoDragDrop(this.tabControl1.SelectedTab,DragDropEffects.All); } } //Target TabControl private void tabControl2_DragEnter(object sender, System.Windows.Forms.DragEventArgs e) { if(e.Data.GetDataPresent(typeof(TabPage))) { e.Effect = DragDropEffects.Move; } else e.Effect = DragDropEffects.None; } private void tabControl2_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { TabPage DropTab = (TabPage)(e.Data.GetData (typeof(TabPage))); this.tabControl2.TabPages.Add (DropTab); } [VB.NET] ’Source TabControl Private Sub tabControl1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) If e.Button = MouseButtons.Left Then Me.tabControl1.DoDragDrop(Me.tabControl1.SelectedTab,DragDropEffects.All) End If End Sub ’Target TabControl Private Sub tabControl2_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) If e.Data.GetDataPresent(Type.GetType(TabPage)) Then e.Effect = DragDropEffects.Move Else e.Effect = DragDropEffects.None End If End Sub Private Sub tabControl2_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Dim DropTab As TabPage = CType((e.Data.GetData(Type.GetType(TabPage))), TabPage) Me.tabControl2.TabPages.Add (DropTab) End Sub

How can I add a hyperlink to a RichTextBox control?

To add a hyperlink to the RichTextBox, so that it opens up the link you click on, ensure that DetectUrls property is set to True and call: [C#] private void richTextBox1_LinkClicked(object sender, System.Windows.Forms.LinkClickedEventArgs e) { System.Diagnostics.Process.Start(e.LinkText); } [VB.NET] Private Sub richTextBox1_LinkClicked(ByVal sender As Object, ByVal e As System.Windows.Forms.LinkClickedEventArgs) System.Diagnostics.Process.Start(e.LinkText) End Sub

How can I copy and paste images/graphs etc from MS Office to a PictureBox?

Since .NET uses it’s own format that is not compatible with the EnhancedMetafile format you will have to use reflection to achieve this. (From a posting in the microsoft.public.dotnet.framework.drawing newsgroup) [C#] using System.Runtime.InteropServices; using System.Reflection; public const uint CF_METAFILEPICT = 3; public const uint CF_ENHMETAFILE = 14; [DllImport(‘user32.dll’, CharSet=CharSet.Auto, ExactSpelling=true)] public static extern bool OpenClipboard(IntPtr hWndNewOwner); [DllImport(‘user32.dll’, CharSet=CharSet.Auto, ExactSpelling=true)] public static extern bool CloseClipboard(); [DllImport(‘user32.dll’, CharSet=CharSet.Auto, ExactSpelling=true)] public static extern IntPtr GetClipboardData(uint format); [DllImport(‘user32.dll’, CharSet=CharSet.Auto, ExactSpelling=true)] public static extern bool IsClipboardFormatAvailable(uint format); //Pasting into PictureBox if (OpenClipboard(this.Handle)) { if (IsClipboardFormatAvailable(CF_ENHMETAFILE)) { IntPtr ptr = GetClipboardData(CF_ENHMETAFILE); if (!ptr.Equals(new IntPtr(0))) { Metafile metafile = new Metafile(ptr,true); //Set the Image Property of PictureBox this.pictureBox1.Image = metafile; } } CloseClipboard(); }