当前位置: 首页>>代码示例>>C#>>正文


C# TextBox.Copy方法代码示例

本文整理汇总了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));
            }
        }
开发者ID:krozen20,项目名称:redshells,代码行数:26,代码来源:WriteClipboardCommand.cs


示例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
     }
 }
开发者ID:AlaaBenFatma,项目名称:SQLic,代码行数:20,代码来源:Main.cs


示例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);
        }
开发者ID:GHScan,项目名称:DailyProjects,代码行数:101,代码来源:Program.cs



注:本文中的System.Windows.Forms.TextBox.Copy方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。