【发布时间】:2011-09-30 21:25:55
【问题描述】:
如何动态更改将粘贴到 TextBox 中的内容。
这是我订阅活动的方式:
DataObject.AddPastingHandler (uiTextBox, TextBoxPaste);
这是我定义事件处理程序的方式:
private void TextBoxPaste (object sender, DataObjectPastingEventArgs args)
{
string clipboard = args.DataObject.GetData (typeof (string)) as string;
Regex nonNumeric = new System.Text.RegularExpressions.Regex (@"\D");
string result = nonNumeric.Replace (clipboard, String.Empty);
// I can't just do "args.DataObject.SetData (result)" here.
}
【问题讨论】: