本文整理汇总了C#中Control.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Control.GetType方法的具体用法?C# Control.GetType怎么用?C# Control.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Control
的用法示例。
在下文中一共展示了Control.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExtractProfileFromControl
internal void ExtractProfileFromControl(Control p_control)
{
if (p_control.GetType().GetMember(PersistableProperty)[0].MemberType != System.Reflection.MemberTypes.Property) return;
object value = p_control.GetType().GetProperty(this.PersistableProperty).GetValue(p_control, null);
this.PropertyValue = value;
}
示例2: CreateControlInternal
protected override void CreateControlInternal(Control control)
{
if (GetProperty<bool>("Windowless") && !(control is Window)) return;
if (handlesByControl.ContainsKey(control)) return;
string className = control.ClassName;
bool classNameRequiresRegistration = true;
if (className == null)
{
if (ControlClassNames.ContainsKey(control.GetType()))
{
className = ControlClassNames[control.GetType()];
classNameRequiresRegistration = false;
}
}
else if (ControlClassNames.ContainsValue(className))
{
classNameRequiresRegistration = false;
}
if (classNameRequiresRegistration)
{
EnsureWindowClassRegistered(className);
}
IntPtr hWndParent = IntPtr.Zero;
if (control.Parent != null)
{
hWndParent = handlesByControl[control.Parent];
}
Rectangle bounds = new Rectangle();
if (control is Window)
{
bounds = ClientBoundsToPhysicalBounds((control as Window).Bounds);
}
else
{
bounds = control.Parent.Layout.GetControlBounds(control);
}
IntPtr handle = Internal.Windows.Methods.User32.CreateWindowEx(GetWindowStylesExForControl(control), className, control.Text, GetWindowStylesForControl(control), (int)bounds.X, (int)bounds.Y, (int)bounds.Width, (int)bounds.Height, hWndParent, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
if (handle != IntPtr.Zero)
{
Font font = control.Font;
if (font == null) font = SystemFonts.MenuFont;
{
font = Font.FromFamily("Tahoma", 10);
}
IntPtr hFont = GetHandleByFont(Internal.Windows.Methods.User32.GetDC(handle), font);
Internal.Windows.Methods.User32.SendMessage(handle, Internal.Windows.Constants.User32.WindowMessages.SetFont, hFont, new IntPtr(1));
controlsByHandle[handle] = control;
handlesByControl[control] = handle;
}
}
示例3: LoadControlFromProfile
internal void LoadControlFromProfile(Control p_control)
{
if (p_control == null || this.PropertyValue == null) return;
if(p_control.GetType().GetMember(PersistableProperty).Length == 0) return;
if (p_control.GetType().GetMember(PersistableProperty)[0].MemberType == System.Reflection.MemberTypes.Property)
{
p_control.GetType().GetProperty(this.PersistableProperty).SetValue(p_control, this.PropertyValue, null);
}
}
示例4: Render
public static IHtmlString Render(this HtmlHelper html, Control control)
{
if (control == null)
{
return MvcHtmlString.Empty;
}
var theme = Theme.Current;
var template = theme.ResolveControl(control.GetType());
if (string.IsNullOrEmpty(template))
{
return MvcHtmlString.Create("there is no template for control " + control.GetType().FullName);
}
return html.Partial(template, control);
}
示例5: ClearControl
public void ClearControl(Control control)
{
switch (control.GetType().Name)
{
case "TextBox":
var txtBox = (TextBox)control;
txtBox.Text = String.Empty;
break;
case "DropDownList":
var ddl = (DropDownList)control;
ddl.SelectedIndex = 0;
break;
case "CheckBox":
var chk = (CheckBox)control;
chk.Checked = false;
break;
case "CheckBoxList":
var chkList = (CheckBoxList)control;
foreach (ListItem li in chkList.Items)
li.Selected = false;
break;
case "Panel":
ClearFields((Panel)control);
break;
case "RadioButtonList":
var rbl = (RadioButtonList)control;
rbl.SelectedIndex = -1;
break;
}
}
示例6: CanRender
/// <summary>
/// Returns <see langword="true"/> if the instance can render <paramref name="control"/>; otherwise <see langword="false"/>.
/// </summary>
/// <param name="control">The control to be rendered.</param>
/// <returns><see langword="true"/> if the instance can render <paramref name="control"/>; otherwise <see langword="false"/>.</returns>
public override bool CanRender(Control control)
{
Type controlType = control.GetType();
return controlType == typeof(HeadingControl)
|| controlType == typeof(LabelControl)
|| controlType == typeof(HtmlControl);
}
示例7: VerifyRenderingInServerForm
public override void VerifyRenderingInServerForm(Control control)
{
if (!(control.GetType().Name.Equals("SmartGridView")))
{
base.VerifyRenderingInServerForm(control);
}
}
示例8: TreeNode
public TreeNode(Control control)
{
Control = control;
Type = control.GetType().Name;
var classesChanged = Observable.FromEventPattern<
NotifyCollectionChangedEventHandler,
NotifyCollectionChangedEventArgs>(
x => control.Classes.CollectionChanged += x,
x => control.Classes.CollectionChanged -= x);
classesChanged.Select(_ => Unit.Default)
.StartWith(Unit.Default)
.Subscribe(_ =>
{
if (control.Classes.Count > 0)
{
Classes = "(" + string.Join(" ", control.Classes) + ")";
}
else
{
Classes = string.Empty;
}
});
}
示例9: Binding
public Binding(Control source, string sourcePropertyName, object target, string targetPropertyName, Func<object,object> targetValueConverter)
{
_targetValueConverter = targetValueConverter;
_target = target;
_targetProperty = target.GetType().GetProperty(targetPropertyName);
_targetField = target.GetType().GetField(targetPropertyName);
_targetMethod = target.GetType().GetMethod(targetPropertyName);
if (_target is INotifyPropertyChanged && _targetMethod == null)
{
(_target as INotifyPropertyChanged).PropertyChanged += TargetPropertyChanged;
}
_source = source;
//If it's the default property we support two way binding
if (sourcePropertyName == null)
{
switch (_source.GetType().Name)
{
case "TextBoxEx":
sourcePropertyName = "Text";
(_source as TextBoxEx).TextChanged += Binding_TextChanged;
(_source as TextBoxEx).CanTextCommit += Binding_CanTextCommit;
(_source as TextBoxEx).TextCommit += Binding_TextCommit;
break;
case "CheckBox":
sourcePropertyName = "Checked";
(_source as CheckBox).CheckedChanged += Binding_CheckedChanged;
break;
case "DropDownList":
sourcePropertyName = "SelectedItem";
(_source as DropDownList).SelectedItemChanged += Binding_SelectedItemChanged;
break;
case "ColorButton":
sourcePropertyName = "Color";
(_source as ColorButton).ColorChanged += Binding_ColorChanged;
break;
}
}
if (sourcePropertyName == null) throw new NotImplementedException(string.Format("No default property defined for control {0}!", _source.GetType().Name));
_sourceProperty = source.GetType().GetProperty(sourcePropertyName);
if (_targetMethod == null) TargetPropertyChanged(_source, null);
}
示例10: ControlCollection
/// <summary>
/// </summary>
public ControlCollection(Control owner)
: base(owner)
{
if (owner == null || owner.GetType() != typeof(MultiPanelPage))
throw new ArgumentNullException("owner", "Tried to create a MultiPanelPage.ControlCollection with a null owner.");
MultiPanelPage c = owner as MultiPanelPage;
if (c == null)
throw new ArgumentException("Tried to create a MultiPanelPage.ControlCollection with a non-MultiPanelPage owner.", "owner");
}
示例11: CanRender
/// <summary>
/// Returns <see langword="true"/> if the instance can render <paramref name="control"/>; otherwise <see langword="false"/>.
/// </summary>
/// <param name="control">The control to be rendered.</param>
/// <returns><see langword="true"/> if the instance can render <paramref name="control"/>; otherwise <see langword="false"/>.</returns>
public bool CanRender(Control control)
{
Type controlType = control.GetType();
return controlType == typeof(CalculationControl)
|| controlType == typeof(FileBrowserControl)
|| controlType == typeof(GeolocationControl)
|| controlType == typeof(HiddenControl)
|| controlType == typeof(SearchControl)
|| controlType == typeof(SummaryControl);
}
示例12: ClearControls
/// <summary>
/// 清除所指定的元件的所有 controls
/// </summary>
private void ClearControls(Control control)
{
for (int i = control.Controls.Count - 1; i >= 0; i--)
{
ClearControls(control.Controls[i]);
}
if (!(control is TableCell))
{
if (control.GetType().GetProperty("SelectedItem") != null)
{
control.Parent.Controls.Remove(control);
}
else if (control.GetType().GetProperty("Text") != null)
{
control.Parent.Controls.Remove(control);
}
}
return;
}
示例13: GenerateControlId
public string GenerateControlId(Control control , int index)
{
if (control.Id != null)
return control.Id;
string name = control.Name;
if (string.IsNullOrEmpty(name))
name = control.GetType().Name;
return name + "_id" + index;
}
示例14: RegistrarScriptBlock
public static void RegistrarScriptBlock(string pstrClave, string pstrScript, Control pctlControl)
{
Page pg_Pagina = (Page)HttpContext.Current.Handler;
if (IsInAsyncPostBack(pg_Pagina))
{
if (pctlControl == null) pctlControl = pg_Pagina;
System.Web.UI.ScriptManager.RegisterClientScriptBlock(pctlControl, pctlControl.GetType(), pstrClave, pstrScript, true);
}
else
{
pg_Pagina.ClientScript.RegisterClientScriptBlock(pg_Pagina.GetType(), pstrClave, pstrScript, true);
}
}
示例15: GetPropertyNames
/// <devdoc>
/// Returns a list of all the propery names for a given control.
/// </devdoc>
private string[] GetPropertyNames(Control control) {
ArrayList array = new ArrayList();
PropertyDescriptorCollection pdc = TypeDescriptor.GetProperties(control.GetType());
foreach (PropertyDescriptor desc in pdc) {
array.Add(desc.Name);
}
array.Sort(Comparer.Default);
return (string[])array.ToArray(typeof(string));
}