本文整理汇总了C#中System.Windows.Forms.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# System.Windows.Forms.GetType方法的具体用法?C# System.Windows.Forms.GetType怎么用?C# System.Windows.Forms.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms
的用法示例。
在下文中一共展示了System.Windows.Forms.GetType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetTo
public void SetTo(Win.Control ct, object value, bool isControlEnabled)
{
string propName = ct.Name.Substring(3);
if (value == null)
{
value = _Row[propName].Value;
}
switch (ct.GetType().Name)
{
case "TextBox":
((Win.TextBox)ct).Text = Convert.ToString(value);
((Win.TextBox)ct).Enabled = isControlEnabled;
break;
case "ComboBox":
((Win.ComboBox)ct).Items.Add(value);
break;
case "Label":
((Win.Label)ct).Text = Convert.ToString(value);
break;
case "DateTimePicker":
DateTime dt;
if (DateTime.TryParse(Convert.ToString(value), out dt))
{
((Win.DateTimePicker)ct).Value = dt;
}
break;
case "ListBox":
((Win.ListBox)ct).Items.Add(value);
break;
case "CheckBox":
bool tempValue;
if (Convert.ToString(value) == "1")
{
tempValue = true;
}
else
{
bool.TryParse(Convert.ToString(value), out tempValue);
}
((Win.CheckBox)ct).Checked = tempValue;
((Win.CheckBox)ct).Enabled = isControlEnabled;
break;
case "NumericUpDown":
decimal result = 0;
if (decimal.TryParse(Convert.ToString(value), out result))
{
((Win.NumericUpDown)ct).Value = result;
}
break;
case "RichTextBox":
((Win.ListBox)ct).Text = Convert.ToString(value);
break;
}
}
示例2: ShowHelpInControl
private void ShowHelpInControl (SWF.Control ctrl)
{
MethodInfo methodInfo = ctrl.GetType ().GetMethod ("WndProc",
BindingFlags.InvokeMethod
| BindingFlags.NonPublic
| BindingFlags.Instance);
HELPINFO info = new HELPINFO ();
SD.Rectangle rectangle = ctrl.TopLevelControl.RectangleToScreen (ctrl.Bounds);
info.MousePos = new POINT (rectangle.X + 5,
rectangle.Y + 5);
IntPtr ptr = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (HELPINFO)));
Marshal.StructureToPtr (info, ptr, false);
SWF.Message message = SWF.Message.Create (ctrl.Handle,
(int) Msg.WM_HELP,
IntPtr.Zero,
ptr);
methodInfo.Invoke (ctrl, new object[] { message });
}
示例3: GetFrom
public void GetFrom(Win.Control ct, object value)
{
string propName = ct.Name.Substring(3);
if (value == null)
{
switch (ct.GetType().Name)
{
case "TextBox":
value = ((Win.TextBox)ct).Text.Trim();
break;
case "ComboBox":
value = ((Win.ComboBox)ct).Text;
break;
case "Label":
value = ((Win.Label)ct).Text;
break;
case "DateTimePicker":
value = ((Win.DateTimePicker)ct).Value;
break;
case "ListBox":
value = ((Win.ListBox)ct).Text;
break;
case "CheckBox":
value = ((Win.CheckBox)ct).Checked;
break;
case "NumericUpDown":
value = ((Win.NumericUpDown)ct).Value;
break;
case "RichTextBox":
value = ((Win.RichTextBox)ct).Text;
break;
}
}
_Row[propName].Value = value;
}