本文整理匯總了C#中System.Windows.Forms.DataObject.SetWrappedData方法的典型用法代碼示例。如果您正苦於以下問題:C# DataObject.SetWrappedData方法的具體用法?C# DataObject.SetWrappedData怎麽用?C# DataObject.SetWrappedData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Windows.Forms.DataObject
的用法示例。
在下文中一共展示了DataObject.SetWrappedData方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: OnKeyDown
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.KeyCode == Keys.Tab || e.KeyCode == Keys.Oemcomma || e.KeyCode == Keys.Return || e.KeyCode == Keys.Space)
{
this.SetFocusEditorIndex((this.focusEditor + 1) % this.editor.Length, true);
e.Handled = true;
}
else if ((e.KeyCode == Keys.C || e.KeyCode == Keys.X) && e.Control)
{
if (this.focusEditor == -1)
{
string valString = this.editor.Select(ve => ve.Value).ToString(", ");
DataObject data = new DataObject();
data.SetText(valString);
data.SetWrappedData(this.DisplayedValue);
Clipboard.SetDataObject(data);
this.SetFocusEditorIndex(-1, true);
if (e.KeyCode == Keys.X)
{
for (int i = 0; i < this.editor.Length; i++)
this.editor[i].Value = 0;
}
e.Handled = true;
}
else
{
this.editor[this.focusEditor].OnKeyDown(e);
}
}
else if (e.KeyCode == Keys.V && e.Control)
{
if (this.focusEditor == -1)
{
DataObject data = Clipboard.GetDataObject() as DataObject;
bool success = false;
if (data.GetWrappedDataPresent(this.DisplayedValue.GetType()))
{
object stored = data.GetWrappedData(this.DisplayedValue.GetType());
this.SetValue(stored);
this.PerformGetValue();
this.OnEditingFinished(FinishReason.LeapValue);
this.SetFocusEditorIndex(-1, true);
success = true;
}
else if (data.ContainsText())
{
string valString = data.GetText();
string[] token = valString.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < Math.Min(token.Length, this.editor.Length); i++)
{
token[i] = token[i].Trim();
decimal val;
if (decimal.TryParse(token[i], out val))
{
this.editor[i].Value = val;
success = true;
}
}
if (success)
{
this.PerformSetValue();
this.PerformGetValue();
this.OnEditingFinished(FinishReason.LeapValue);
this.SetFocusEditorIndex(-1, true);
}
}
if (!success) System.Media.SystemSounds.Beep.Play();
e.Handled = true;
}
else
{
this.editor[this.focusEditor].OnKeyDown(e);
}
}
else
{
if (this.focusEditor != -1)
this.editor[this.focusEditor].OnKeyDown(e);
else
{
for (int i = 0; i < this.editor.Length; i++)
{
this.editor[i].OnKeyDown(e);
if (e.Handled)
{
this.SetFocusEditorIndex(i, false);
break;
}
}
}
}
base.OnKeyDown(e);
}