private Button NewCopyFilteredButton(TextBox parentTextBox, RecordType recordType, string tipText = null, char[] allowedCopyCharacters = null, GetText copyText = null) { parentTextBox.Width -= parentTextBox.Height; var button = new Button() { Name = "btnCopyFiltered", Location = new Point(parentTextBox.Right, parentTextBox.Top), Size = new Size(parentTextBox.Height, parentTextBox.Height), TabStop = false, Tag = parentTextBox, Text = "", Anchor = AnchorStyles.Top | AnchorStyles.Right }; Helpers.ScaleButton(button); tip.SetToolTip(button, tipText ?? "Copy to clipboard."); button.Click += (object sender, EventArgs e) => { var textBox = (TextBox)(((Control)sender).Tag); textBox.Select(); string text; if (copyText != null) { text = copyText.Invoke(); } else { text = textBox.Text; } text = Helpers.FilterText(text, allowedCopyCharacters); ClipboardHelper.SetClipboardText(this, text, recordType); }; return(button); }