![](/img/trans.png)
[英]How do I make an if statement goto a point when a certain input is entered? Microsoft Visual Studio C#
[英]How do i make a button that inserts A Certain text into a textbox in Visual Studio C#?
我如何制作一個按鈕來插入我在 Visual Studio 中制作的文本?
基本上,我如何制作一個像剪貼板一樣的按鈕?
是否要將文本保存到剪貼板並將其插入文本框?
如果是這樣,您可以參考以下代碼。
// Save some text to clipboard to test
private void btnSavetoClipboard_Click(object sender, EventArgs e)
{
Clipboard.SetDataObject("test string in clipboard");
}
// Read the text from clipboard
private void btInsert_Click(object sender, EventArgs e)
{
IDataObject iData = Clipboard.GetDataObject();
if (iData.GetDataPresent(DataFormats.Text))
{
textBox.Text = (String)iData.GetData(DataFormats.Text);
}
}
如果沒有,請提供更詳細的信息。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.