PDA

View Full Version : سوال: شبیه سازی CUT در سی شارپ



Meysam136611
دوشنبه 14 تیر 1395, 12:38 عصر
سلام دوستان.چطور میشه عملیات CUT توی نوت پد رو در سی شارپ پیاده سازی کرد.لطفا کمکم کنید

reza_ali202000
دوشنبه 14 تیر 1395, 13:01 عصر
سلام دوست عزیز

oing is copying the selected text to the clipboard, and then deleting the selected text. As I said I know the syntax is wrong I'm just trying to show what I'm attempting to do.

private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
{
textBox1.Text = Clipboard.GetText(); // will paste whatever text is copied to clipboard
}
private void copyToolStripMenuItem_Click(object sender, EventArgs e)
{
Clipboard.SetText(textBox1.SelectedText);//copies whatever text is selected in my textbox
}
private void clearClipboardToolStripMenuItem_Click(object sender, EventArgs e)
{
Clipboard.Clear();//clears clipboard
}
private void cutToolStripMenuItem_Click(object sender, EventArgs e)
{
Clipboard.SetText(textBox1.SelectedText);
textBox1.SelectedText == "";//line I know is incorrect
}

mn_acer1
دوشنبه 14 تیر 1395, 22:13 عصر
خیلی سادست فقط کافیه بزنی Textbox.cut()

if(textBox1.SelectedText != "")
textBox1.Cut();


منبع (https://msdn.microsoft.com/en-us/library/system.windows.forms.textboxbase.cut(v=vs.100).asp x)