本文整理汇总了C#中System.Windows.Forms.TextBox.Copy方法的典型用法代码示例。如果您正苦于以下问题:C# TextBox.Copy方法的具体用法?C# TextBox.Copy怎么用?C# TextBox.Copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.TextBox
的用法示例。
在下文中一共展示了TextBox.Copy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessRecord
protected override void ProcessRecord()
{
var files = Directory.GetFiles(SessionState.Path.CurrentLocation.Path, SearchPattern);
if (files.Length > 0)
{
StringBuilder builder = new StringBuilder();
foreach (var file in files)
{
builder.AppendLine(file);
}
TextBox clipStore = new TextBox();
clipStore.Text = builder.ToString();
clipStore.Multiline = true;
clipStore.SelectAll();
clipStore.Copy();
WriteObject(string.Format("({0}) files copied.", files.Length));
}
else
{
WriteError(new ErrorRecord(new NullReferenceException("No Files to copy"), "0301", ErrorCategory.InvalidArgument, files));
}
}
示例2: copyUrlToolStripMenuItem_Click
/// <summary>
/// Copy url
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void copyUrlToolStripMenuItem_Click(object sender, EventArgs e)
{
string str = "";
TextBox tb = new TextBox();
try
{
tb.Text = Target.Text + Tree.SelectedNode.Text;
tb.SelectAll();
tb.Copy();
}
catch
{
//ignored
}
}
示例3: Main
//.........这里部分代码省略.........
textBoxOutput.Text = "";
var commonUse = new List<string>();
commonUse.Add(Encoding.Unicode.WebName);
commonUse.Add(Encoding.UTF8.WebName);
commonUse.Add(Encoding.Default.WebName);
commonUse.Add(Encoding.UTF7.WebName);
commonUse.Add(Encoding.UTF32.WebName);
var fullList = Encoding.GetEncodings().Select(i=>i.GetEncoding().WebName);
comboBox.DataSource = commonUse.Concat(fullList.Except(commonUse)).ToArray();
};
radioButtonNumber.Click += (o, e) =>
{
textBoxInput.Text = "";
textBoxOutput.Text = "";
comboBox.DataSource = new string[] { "unsigned oct", "signed oct", "hex", };
};
radioButtonText.PerformClick();
Func<byte[], string> formatBytes = bytes =>
{
if (bytes == null || bytes.Length == 0) return string.Empty;
var buf = new StringBuilder();
foreach (byte b in bytes) buf.AppendFormat("{0:x2} ", b);
buf.Remove(buf.Length - 1, 1);
return buf.ToString();
};
EventHandler intput2output = (o, e) =>
{
textBoxOutput.Text = string.Empty;
if (string.IsNullOrEmpty(textBoxInput.Text)) return;
if (radioButtonText.Checked)
{
try
{
Encoding encoding = Encoding.GetEncoding(comboBox.Text);
textBoxOutput.Text = formatBytes(encoding.GetBytes(textBoxInput.Text));
}
catch (Exception _e)
{
statusLabel.Text = _e.Message.Replace("\r\n", "\t");
}
}
else
{
try
{
if (comboBox.Text == "hex")
{
uint i = uint.Parse(textBoxInput.Text, System.Globalization.NumberStyles.HexNumber);
textBoxOutput.Text = formatBytes(ToByteArray(i));
}
else if (comboBox.Text == "signed oct")
{
int i = int.Parse(textBoxInput.Text);
textBoxOutput.Text = formatBytes(ToByteArray(i));
}
else if (comboBox.Text == "unsigned oct")
{
uint i = uint.Parse(textBoxInput.Text);
textBoxOutput.Text = formatBytes(ToByteArray(i));
}
else
{
statusLabel.Text = "未知的格式。";
}
}
catch (Exception _e)
{
statusLabel.Text = _e.Message.Replace("\r\n", "\t");
}
}
};
textBoxInput.TextChanged += intput2output;
comboBox.SelectedValueChanged += intput2output;
textBoxOutput.DoubleClick += (o, e) =>
{
if (string.IsNullOrEmpty(textBoxOutput.Text)) return;
textBoxOutput.SelectAll();
textBoxOutput.Copy();
statusLabel.Text = "复制到剪贴板。";
};
Timer timerCleanStatus = new Timer();
timerCleanStatus.Interval = 3000;
timerCleanStatus.Tick += (o, e) => { statusLabel.Text = ""; };
timerCleanStatus.Start();
Application.Run(form);
}