我有很多文本框.我有一个按钮,可以剪切聚焦文本框的选定文本.我怎么做?我试过这个:
if (((TextBox)(pictureBox1.Controls[0])).SelectionLength > 0)
{
((TextBox)(pictureBox1.Controls[0])).Cut();
}
Run Code Online (Sandbox Code Playgroud)
希望它是WinForms
var textboxes = (from textbox in this.Controls.OfType<TextBox>()
where textbox.SelectedText != string.Empty
select textbox).FirstOrDefault();
if (textboxes != null)
{
textboxes.Cut();
}
Run Code Online (Sandbox Code Playgroud)