本文整理汇总了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);
}