System.Windows.Forms.Clipboard.SetText(string)

Here are the examples of the csharp api class System.Windows.Forms.Clipboard.SetText(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

200 Examples 7

1. Example

Project: xsddiagram
Source File: MainForm.cs
View license
private void ListViewToString(ListView listView, bool selectedLineOnly)
		{
			string result = "";
			if (selectedLineOnly)
			{
				if (listView.SelectedItems.Count > 0)
				{
					foreach (ColumnHeader columnHeader in listView.Columns)
					{
						if (columnHeader.Index > 0) result += "\t";
						result += listView.SelectedItems[0].SubItems[columnHeader.Index].Text;
					}
				}
			}
			else
			{
				foreach (ListViewItem lvi in listView.Items)
				{
					foreach (ColumnHeader columnHeader in listView.Columns)
					{
						if (columnHeader.Index > 0) result += "\t";
						result += lvi.SubItems[columnHeader.Index].Text;
					}
					result += "\r\n";
				}
			}
			if (result.Length > 0)
				Clipboard.SetText(result);
		}

2. Example

Project: NSMB-Editor
Source File: LevelEditorControl.cs
View license
public void copy()
        {
            string str = mode.copy();
            if (str.Length > 0)
                Clipboard.SetText(clipHeader + str + clipFooter);
        }

3. Example

Project: v2rayN
Source File: Utils.cs
View license
public static void SetClipboardData(string strData)
        {
            try
            {
                Clipboard.SetText(strData);            
            }
            catch
            {
            }
        }

4. Example

View license
private void button10_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedItem!=null)
            {
                var itm = (PLCTag) listBox1.SelectedItem;
                string ret = itm.S7FormatAddress + "\n";
                foreach (var oldValue in itm.OldValues)
                {
                    ret += oldValue.ToString() + "\n";
                }

                Clipboard.SetText(ret);
            }
        }

5. Example

Project: WsdlUI
Source File: uc_TreeView.cs
View license
private void copyUriToClipboardToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string uri = tv_webServices.SelectedNode.Name;
            Clipboard.SetText(uri);
        }

6. Example

Project: EDDiscovery
Source File: UserControlRoute.cs
View license
private void dataGridViewRoute_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewCell cell = dataGridViewRoute.CurrentCell;
            if (cell != null)
                Clipboard.SetText((string)cell.Value);        }

7. Example

Project: FOCA
Source File: Contextual.cs
View license
public static void Global(TreeNode tn, Control sourceControl)
        {
            var tsiCopyClipboard = new ToolStripMenuItem("&Copy to clipboard") { Image = Resources.copytToClipboard };

            tsiCopyClipboard.Click += delegate { Clipboard.SetText(tn.Text); };

            Program.FormMainInstance.contextMenu.Items.Add(tsiCopyClipboard);
            Program.FormMainInstance.contextMenu.Items.Add(new ToolStripSeparator());

#if PLUGINS
            if (Program.FormMainInstance.ManagePluginsApi.lstContextGlobal.Count <= 0) return;
            foreach (
                var tsiPlugin in
                    Program.FormMainInstance.ManagePluginsApi.lstContextGlobal.Select(pluginMenu => pluginMenu.item))
            {
                tsiPlugin.Tag = tn.Tag;
                Program.FormMainInstance.contextMenu.Items.Add(tsiPlugin);
            }
#endif
        }

8. Example

Project: FOCA
Source File: PanelMetadataSearch.cs
View license
private void toolStripMenuItemCopyToClipboard_Click(object sender, EventArgs e)
        {
            var links = string.Empty;
            for (var i = 0; i < listViewDocuments.SelectedItems.Count; i++)
            {
                //Add newlines
                links += i != 0 ? Environment.NewLine : string.Empty;
                links += listViewDocuments.SelectedItems[i].SubItems[2].Text;
            }
            Clipboard.SetText(links);
            Program.LogThis(new Log(Log.ModuleType.MetadataSearch,
                $"Copied to clipboard {listViewDocuments.SelectedItems.Count} URL documents",
                Log.LogType.debug));
        }

9. Example

Project: ACT.TPMonitor
Source File: ACTTabpageControl.cs
View license
private void buttonCopy_Click(object sender, EventArgs e)
        {
            Clipboard.SetText(textBoxRecommend.Text);
        }

10. Example

Project: gitextensions
Source File: CommitInfo.cs
View license
private void copyCommitInfoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var commitInfo = string.Empty;
            if (EnvUtils.IsMonoRuntime())
            {
                commitInfo = $"{_RevisionHeader.Text}{Environment.NewLine}{RevisionInfo.Text}";
            }
            else
            {
                commitInfo = $"{_RevisionHeader.GetPlaintText()}{Environment.NewLine}{RevisionInfo.GetPlaintText()}";
            }
            Clipboard.SetText(commitInfo);
        }

11. Example

View license
private void CopyToClipboard(int what)
        {
            if (functionList != null )
            {
                string text = string.Empty;
                for (int i = dataGridFunctions.SelectedRows.Count - 1; i >= 0; i--)
                {
                    int row = dataGridFunctions.Rows.IndexOf(dataGridFunctions.SelectedRows[i]);
                    switch (what)
                    {
                        case 1:
                            text += functionList.functions[row].address.ToString("X") + Environment.NewLine;
                            break;
                        case 2:
                            text += functionList.functions[row].name + Environment.NewLine;
                            break;
                        default:
                            text += functionList.functions[row].address.ToString("X") +
                                    "\t" + functionList.functions[row].name + Environment.NewLine;
                            break;
                    }
                }
                if (text != string.Empty)
                {
                    Clipboard.SetText(text);
                }
            }
        }

12. Example

Project: Grevit
Source File: ParameterList.cs
View license
private void copyID_Click(object sender, EventArgs e)
        {
            if (parameters.SelectedItems.Count == 1)
            {
                string elementId = parameters.SelectedItems[0].SubItems[0].Text;
                Clipboard.SetText(elementId);
            }
        }

13. Example

Project: Grevit
Source File: ParameterList.cs
View license
private void copyName_Click(object sender, EventArgs e)
        {
            if (parameters.SelectedItems.Count == 1)
            {
                string name = parameters.SelectedItems[0].SubItems[1].Text;
                Clipboard.SetText(name);
            }
        }

14. Example

Project: Rosin
Source File: JsonViewer.cs
View license
private void btnCopy_Click(object sender, EventArgs e)
        {
            string text;
            if (txtJson.SelectionLength > 0)
                text = txtJson.SelectedText;
            else
                text = txtJson.Text;
            Clipboard.SetText(text);
        }

15. Example

Project: VSIXPowerToys
Source File: VsixPowerToys.cs
View license
private void CopyVsixIdToClipboard()
        {
            Clipboard.SetText(vsix.Header.Identifier);
        }

16. Example

Project: Kuriimu
Source File: Extension.cs
View license
private void copyOffsetToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (lstStatus.SelectedItem != null && lstStatus.SelectedItem.GetType() == typeof(ListItem))
                Clipboard.SetText((string)((ListItem)lstStatus.SelectedItem).Value);
        }

17. Example

Project: Kuriimu
Source File: Extension.cs
View license
private void lstStatus_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Control & e.KeyCode == Keys.C)
                if (lstStatus.SelectedItem != null && lstStatus.SelectedItem.GetType() == typeof(ListItem))
                    Clipboard.SetText((string)((ListItem)lstStatus.SelectedItem).Value);
        }

18. Example

Project: AuthorizationServer
Source File: Program.cs
View license
private static void SetClipboard(string text)
        {
            Clipboard.SetText(text);
        }

19. Example

Project: opentheatre
Source File: ctrlStreamInfo.cs
View license
private void imgCopyURL_Click(object sender, EventArgs e)
        {
            Clipboard.SetText(infoFileURL);
            imgCopyURL.Image = Properties.Resources.clipboard_check;
        }

20. Example

View license
private void Resource_MouseDoubleClick(object sender, MouseEventArgs e)
		{
			if (e.Button == MouseButtons.Left)
			{
				try
				{
					var mat = KCDatabase.Instance.Material;
					Clipboard.SetText($"{mat.Fuel}/{mat.Ammo}/{mat.Steel}/{mat.Bauxite}/??{mat.InstantRepair}/??{mat.DevelopmentMaterial}/??{mat.InstantConstruction}/??{mat.ModdingMaterial}");
				}
				catch (Exception ex)
				{
					Utility.Logger.Add(3, "???????????????????????" + ex.Message);
				}
			}
		}

21. Example

Project: IFME
Source File: frmAbout.cs
View license
private void lblDonateBTC_Click(object sender, EventArgs e)
		{
			Clipboard.SetText("12LWHDCPShFvYh6vxxeMsntejAUm8y8rFN");
			lblDonateBTC.ForeColor = Color.Purple;
		}

22. Example

Project: IFME
Source File: frmAbout.cs
View license
private void lblDonateETH_Click(object sender, EventArgs e)
		{
			Clipboard.SetText("0xAdd9ba89B601e7CB5B3602643337B9db8c90EFe0");
			lblDonateETH.ForeColor = Color.Purple;
		}

23. Example

Project: FileHelpers
Source File: frmWizard.cs
View license
private void cmdToClipboard_Click(object sender, EventArgs e)
        {
            Clipboard.SetText(mLastTemplateCode);
        }

24. Example

Project: FileHelpers
Source File: frmWizard.cs
View license
private void cmdCopyClass_Click(object sender, EventArgs e)
        {
            Clipboard.SetText(mLastCode);
        }

25. Example

Project: Captura
Source File: Extensions.cs
View license
public static void WriteToClipboard(this string S)
        {
            if (S == null)
                return;

            try { Clipboard.SetText(S); }
            catch (ExternalException)
            {
                ServiceProvider.MessageProvider?.ShowError($"Copy to Clipboard failed:\n\n{S}");
            }
        }

26. Example

View license
public void CopyTag(string tag) {
            try {
                Clipboard.SetText("[" + tag + "]");
            }
            catch {
                // Do nothing
            }
        }

27. Example

Project: Pass4Win
Source File: Genpass.cs
View license
private void BtnCopyClick(object sender, EventArgs e)
        {
            if (txtGenPass.Text != null)
            {
                Clipboard.SetText(new string(txtGenPass.Text.TakeWhile(c => c != '\n').ToArray()));
            }
        }

28. Example

Project: MOSA-Project
Source File: MainForm.cs
View license
public void OnCopyToClipboard(Object sender, EventArgs e)
		{
			var text = (sender as Menu).Tag as string;

			Clipboard.SetText(text);
		}

29. Example

Project: Tibialyzer
Source File: SummaryForm.cs
View license
private void CopyLootText(object sender, EventArgs e) {
            Clipboard.SetText((sender as Control).Name);
        }

30. Example

View license
private void CopyLootText(object sender, EventArgs e) {
            Clipboard.SetText((sender as Control).Name);
        }

31. Example

Project: cardmaker
Source File: MDIDefines.cs
View license
private void copyDefineAsReferenceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (1 == listViewDefines.SelectedItems.Count)
            {
                Clipboard.SetText($"@[{listViewDefines.SelectedItems[0].SubItems[0].Text}]");
            }
        }

32. Example

Project: nHydrate
Source File: StaticDataForm.cs
View license
private void cmdCopy_Click(object sender, EventArgs e)
        {
            var text = "";
            var table = (DataTable)this.dataGridView1.DataSource;
            var jj = 0;
            foreach (DataRow dr in table.Rows)
            {
                for (var ii = 0; ii < table.Columns.Count; ii++)
                {
                    text += dr[ii];
                    if (ii < table.Columns.Count - 1)
                        text += "\t";
                }

                if (jj < table.Rows.Count - 1)
                    text += "\n";

                jj++;
            }
            Clipboard.SetText(text);
        }

33. Example

Project: nHydrate
Source File: RowEntryCollectionForm.cs
View license
private void cmdCopy_Click(object sender, EventArgs e)
		{
			var text = string.Empty;
			var table = (DataTable)this.dataGridView1.DataSource;
			var jj = 0;
			foreach (DataRow dr in table.Rows)
			{
				for (var ii = 0; ii < table.Columns.Count; ii++)
				{
					text += dr[ii];
					if (ii < table.Columns.Count - 1)
						text += "\t";
				}

				if (jj < table.Rows.Count - 1)
					text += "\n";

				jj++;
			}
			Clipboard.SetText(text);
		}

34. Example

View license
[Test]
        [Ignore("System.Threading.ThreadStateException : Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it.")]
        [STAThread]
        public void RestrictedProcessShouldNotBeAbleToReadClipboard()
        {
            const string ReadClipboardSourceCode = @"using System;
using System.Windows.Forms;
class Program
{
    public static void Main()
    {
        if (string.IsNullOrEmpty(Clipboard.GetText()))
        {
            throw new Exception(""Clipboard empty!"");
        }
    }
}";
            Clipboard.SetText("clipboard test");
            var exePath = this.CreateExe("RestrictedProcessShouldNotBeAbleToReadClipboard.exe", ReadClipboardSourceCode);

            var process = new RestrictedProcessExecutor();
            var result = process.Execute(exePath, string.Empty, 1500, 32 * 1024 * 1024);

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Type == ProcessExecutionResultType.RunTimeError, "No exception is thrown!");
        }

35. Example

Project: monogameui
Source File: SystemSpecific.cs
View license
public static void SetClipboardText(string text)
        {
            System.Windows.Forms.Clipboard.SetText(text);
        }

36. Example

View license
private void buttonCopyToClipboard_Click(object sender, EventArgs e)
        {
            string expressionName = radPageViewGeneratedText.SelectedPage.Text;

            var expressionText = _dicTexts[expressionName];
            Clipboard.SetText(expressionText);
        }

37. Example

View license
private void copyValueToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (null == treeViewProperties.SelectedNode) return;

            string value = treeViewProperties.SelectedNode.Tag as string;
            if (null != value)
            {
                System.Windows.Forms.Clipboard.SetText(value);
            }
        }

38. Example

View license
private void copyRowToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (null == treeViewProperties.SelectedNode) return;

            string value = treeViewProperties.SelectedNode.Text;
            if (null != value)
            {
                System.Windows.Forms.Clipboard.SetText(value);
            }
        }

39. Example

Project: QuasarRAT
Source File: ClipboardHelper.cs
View license
public static void SetClipboardText(string text)
        {
            try
            {
                Clipboard.SetText(text);
            }
            catch (Exception)
            {
            }
        }

40. Example

Project: scada
Source File: FrmMain.cs
View license
private void lbLog_KeyDown(object sender, KeyEventArgs e)
        {
            // ??????????? ????????? ?????? ???????
            ListBox listBox = (ListBox)sender;
            if (e.KeyCode == Keys.C && e.Modifiers == Keys.Control)
            {
                lock (listBox)
                {
                    if (listBox.SelectedIndex >= 0)
                    {
                        string text = listBox.Items[listBox.SelectedIndex] as string ?? "";
                        if (text != "")
                            Clipboard.SetText(text);
                    }
                }
            }
        }

41. Example

View license
private void CopyPACURLItem_Click(object sender, EventArgs e)
        {
            try
            {
                Configuration config = controller.GetCurrentConfiguration();
                string pacUrl;
                pacUrl = "http://127.0.0.1:" + config.localPort.ToString() + "/pac?" + "auth=" + config.localAuthPassword + "&t=" + Util.Utils.GetTimestamp(DateTime.Now);
                Clipboard.SetText(pacUrl);
            }
            catch
            {

            }
        }

42. Example

View license
private void copyLinkItem_Click(object sender, EventArgs e)
        {
            Configuration config = controller.GetCurrentConfiguration();
            if (config.index >= 0 && config.index < config.configs.Count)
            {
                try
                {
                    string link = config.configs[config.index].GetSSRLinkForServer();
                    Clipboard.SetText(link);
                }
                catch { }
            }
        }

43. Example

View license
private void copyGroupLinkItem_Click(object sender, EventArgs e)
        {
            Configuration config = controller.GetCurrentConfiguration();
            if (config.index >= 0 && config.index < config.configs.Count)
            {
                string group = config.configs[config.index].group;
                string link = "";
                for (int index = 0; index < config.configs.Count; ++index)
                {
                    if (config.configs[index].group != group)
                        continue;
                    link += config.configs[index].GetSSRLinkForServer() + "\r\n";
                }
                try
                {
                    Clipboard.SetText(link);
                }
                catch { }
            }
        }

44. Example

View license
private void copyEnableLinksItem_Click(object sender, EventArgs e)
        {
            Configuration config = controller.GetCurrentConfiguration();
            string link = "";
            for (int index = 0; index < config.configs.Count; ++index)
            {
                if (!config.configs[index].enable)
                    continue;
                link += config.configs[index].GetSSRLinkForServer() + "\r\n";
            }
            try
            {
                Clipboard.SetText(link);
            }
            catch { }
        }

45. Example

View license
private void copyLinksItem_Click(object sender, EventArgs e)
        {
            Configuration config = controller.GetCurrentConfiguration();
            string link = "";
            for (int index = 0; index < config.configs.Count; ++index)
            {
                link += config.configs[index].GetSSRLinkForServer() + "\r\n";
            }
            try
            {
                Clipboard.SetText(link);
            }
            catch { }
        }

46. Example

Project: Repetier-Host
Source File: LogView.cs
View license
private void toolCopy_Click(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();
            string sel = listLog.getSelection();
            if(sel.Length>0)
                Clipboard.SetText(sel);
        }

47. Example

View license
private void CopyPACURLItem_Click(object sender, EventArgs e)
        {
            try
            {
                Configuration config = controller.GetCurrentConfiguration();
                string pacUrl;
                pacUrl = "http://127.0.0.1:" + config.localPort.ToString() + "/pac?" + "auth=" + config.localAuthPassword + "&t=" + Util.Utils.GetTimestamp(DateTime.Now);
                Clipboard.SetText(pacUrl);
            }
            catch
            {

            }
        }

48. Example

View license
private void copyLinkItem_Click(object sender, EventArgs e)
        {
            Configuration config = controller.GetCurrentConfiguration();
            if (config.index >= 0 && config.index < config.configs.Count)
            {
                try
                {
                    string link = config.configs[config.index].GetSSRLinkForServer();
                    Clipboard.SetText(link);
                }
                catch { }
            }
        }

49. Example

View license
private void copyGroupLinkItem_Click(object sender, EventArgs e)
        {
            Configuration config = controller.GetCurrentConfiguration();
            if (config.index >= 0 && config.index < config.configs.Count)
            {
                string group = config.configs[config.index].group;
                string link = "";
                for (int index = 0; index < config.configs.Count; ++index)
                {
                    if (config.configs[index].group != group)
                        continue;
                    link += config.configs[index].GetSSRLinkForServer() + "\r\n";
                }
                try
                {
                    Clipboard.SetText(link);
                }
                catch { }
            }
        }

50. Example

View license
private void copyEnableLinksItem_Click(object sender, EventArgs e)
        {
            Configuration config = controller.GetCurrentConfiguration();
            string link = "";
            for (int index = 0; index < config.configs.Count; ++index)
            {
                if (!config.configs[index].enable)
                    continue;
                link += config.configs[index].GetSSRLinkForServer() + "\r\n";
            }
            try
            {
                Clipboard.SetText(link);
            }
            catch { }
        }