当前位置: 首页>>代码示例>>C#>>正文


C# Control.GetType方法代码示例

本文整理汇总了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;
    }
开发者ID:benkitzelman,项目名称:ProfilePersistence,代码行数:7,代码来源:UrlProfile.cs

示例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;
            }
        }
开发者ID:alcexhim,项目名称:UniversalWidgetToolkit,代码行数:58,代码来源:Win32Engine.cs

示例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);
        }
    }
开发者ID:benkitzelman,项目名称:ProfilePersistence,代码行数:11,代码来源:UrlProfile.cs

示例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);
 }
开发者ID:yangwen27,项目名称:moonlit,代码行数:14,代码来源:Control.cs

示例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;
     }
 }
开发者ID:lifetofree,项目名称:messis-web,代码行数:30,代码来源:FunctionWeb.cs

示例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);
 }
开发者ID:cgavieta,项目名称:WORKPAC2016-poc,代码行数:12,代码来源:ContentControlRenderer.cs

示例7: VerifyRenderingInServerForm

 public override void VerifyRenderingInServerForm(Control control)
 {
     if (!(control.GetType().Name.Equals("SmartGridView")))
         {
             base.VerifyRenderingInServerForm(control);
         }
 }
开发者ID:SoMeTech,项目名称:SoMeRegulatory,代码行数:7,代码来源:bt.aspx.cs

示例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;
                    }
                });
        }
开发者ID:Arlorean,项目名称:Perspex,代码行数:25,代码来源:TreeNode.cs

示例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);
        }
开发者ID:Tokter,项目名称:TokED,代码行数:46,代码来源:Bindings.cs

示例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");
 }
开发者ID:ennerperez,项目名称:multipanelcontrol,代码行数:11,代码来源:MultiPanelPage.cs

示例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);
 }
开发者ID:cgavieta,项目名称:WORKPAC2016-poc,代码行数:15,代码来源:EmptyControlRenderer.cs

示例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;
    }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:23,代码来源:POP_CAA111_CLOSE.aspx.cs

示例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;
        }
开发者ID:marinehero,项目名称:ThinkAway.net,代码行数:12,代码来源:DefaultControlIdGenerator.cs

示例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);
     }
 }
开发者ID:helbert959,项目名称:Sistema_Control_Pedidos_net,代码行数:13,代码来源:CScript.cs

示例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));
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:17,代码来源:ControlPropertyNameConverter.cs


注:本文中的Control.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。