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


C# PropertyGrid.GetType方法代码示例

本文整理汇总了C#中System.Windows.Forms.PropertyGrid.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyGrid.GetType方法的具体用法?C# PropertyGrid.GetType怎么用?C# PropertyGrid.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.PropertyGrid的用法示例。


在下文中一共展示了PropertyGrid.GetType方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetSelectedTabInPropertyGrid

        // The PropertyGrid doesn't provide a settable SelectedTab property. Well, it does now.
        public static void SetSelectedTabInPropertyGrid(PropertyGrid propGrid, int selectedTabIndex)
        {
            if ((selectedTabIndex < 0) || (selectedTabIndex >= propGrid.PropertyTabs.Count))
            {
                throw new ArgumentException("Invalid tab index to select: " + selectedTabIndex);
            }

            FieldInfo buttonsField = propGrid.GetType().GetField("viewTabButtons", BindingFlags.NonPublic | BindingFlags.Instance);
            ToolStripButton[] viewTabButtons = (ToolStripButton[])buttonsField.GetValue(propGrid);
            ToolStripButton viewTabButton = viewTabButtons[selectedTabIndex];

            propGrid.GetType().InvokeMember("OnViewTabButtonClick", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, propGrid, new object[] { viewTabButton, EventArgs.Empty });
        }
开发者ID:smarinel,项目名称:ags-web,代码行数:14,代码来源:Hacks.cs

示例2: ResizePropertyGridDescriptionArea

        private static bool ResizePropertyGridDescriptionArea(PropertyGrid propertyGrid, int lines)
        {
            try
            {
                PropertyInfo propertyInfo = propertyGrid.GetType().GetProperty("Controls");
                Control.ControlCollection controlCollection = (Control.ControlCollection)propertyInfo.GetValue(propertyGrid, null);

                foreach (Control control in controlCollection)
                {
                    Type type = control.GetType();
                    string typeName = type.Name;

                    if (typeName == "DocComment")
                    {
                        propertyInfo = type.GetProperty("Lines");
                        propertyInfo.SetValue(control, lines, null);

                        FieldInfo fieldInfo = type.BaseType.GetField("userSized", BindingFlags.Instance | BindingFlags.NonPublic);
                        fieldInfo.SetValue(control, true);
                    }
                }

                return true;
            }
            catch (Exception)
            {
                return false;
            }
        }
开发者ID:beta-tester,项目名称:FpRam-Editor,代码行数:29,代码来源:FormMain.cs

示例3: SetLabelColumnWidth

        public static void SetLabelColumnWidth(PropertyGrid grid, int width)
        {
            if (grid == null)
                throw new ArgumentNullException("grid");

            // get the grid view
            Control view = (Control)grid.GetType().GetField("gridView", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(grid);

            // set label width
            FieldInfo fi = view.GetType().GetField("labelWidth", BindingFlags.Instance | BindingFlags.NonPublic);
            fi.SetValue(view, width);

            // refresh
            view.Invalidate();
        }
开发者ID:Corey-M,项目名称:Misc,代码行数:15,代码来源:Form1.cs

示例4: ResizeDescriptionArea

        private void ResizeDescriptionArea(PropertyGrid grid, int lines)
        {
            try
            {
                var info = grid.GetType().GetProperty("Controls");
                var collection = (Control.ControlCollection)info.GetValue(grid, null);

                foreach (var control in collection)
                {
                    var type = control.GetType();

                    if ("DocComment" == type.Name)
                    {
                        const BindingFlags Flags = BindingFlags.Instance | BindingFlags.NonPublic;
                        var field = type.BaseType.GetField("userSized", Flags);
                        field.SetValue(control, true);

                        info = type.GetProperty("Lines");
                        info.SetValue(control, lines, null);

                        grid.HelpVisible = true;
                        break;
                    }
                }
            }

            catch (Exception ex)
            {
                Trace.WriteLine(ex);
            }
        }
开发者ID:xtremas,项目名称:FontTool,代码行数:31,代码来源:Editor.cs

示例5: GetAllGridEntries

 public static GridItemCollection GetAllGridEntries(PropertyGrid grid)
 {
     object view = grid.GetType().GetField("gridView", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(grid);
     return (GridItemCollection)view.GetType().InvokeMember("GetAllGridEntries", BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance, null, view, null);
 }
开发者ID:cnark,项目名称:Seal-Report,代码行数:5,代码来源:Helper.cs

示例6: Load

        public static void Load(PropertyGrid control)
        {
            if (control == null) { throw new ArgumentNullException("control", "Control is null."); }

            string baseValueName = Helper.GetControlPath(control);

            try {
                control.PropertySort = (System.Windows.Forms.PropertySort)(Helper.Read(baseValueName + ".PropertySort", System.Convert.ToInt32(control.PropertySort, System.Globalization.CultureInfo.InvariantCulture)));
            } catch (System.ComponentModel.InvalidEnumArgumentException) { }

            System.Reflection.FieldInfo fieldGridView = control.GetType().GetField("gridView", System.Reflection.BindingFlags.GetField | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
            object gridViewObject = fieldGridView.GetValue(control);
            if (gridViewObject != null) {
                int currentlabelWidth = 0;
                System.Reflection.PropertyInfo propertyInternalLabelWidth = gridViewObject.GetType().GetProperty("InternalLabelWidth", System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                if (propertyInternalLabelWidth != null) {
                    object val = propertyInternalLabelWidth.GetValue(gridViewObject, null);
                    if (val is int) {
                        currentlabelWidth = (int)val;
                    }
                }
                int labelWidth = Helper.Read(baseValueName + ".LabelWidth", currentlabelWidth);
                if ((labelWidth > 0) && (labelWidth < control.Width)) {
                    System.Reflection.BindingFlags methodMoveSplitterToFlags = System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance;
                    System.Reflection.MethodInfo methodMoveSplitterTo = gridViewObject.GetType().GetMethod("MoveSplitterTo", methodMoveSplitterToFlags);
                    if (methodMoveSplitterTo != null) {
                        methodMoveSplitterTo.Invoke(gridViewObject, methodMoveSplitterToFlags, null, new object[] { labelWidth }, System.Globalization.CultureInfo.CurrentCulture);
                    }
                }
            }
        }
开发者ID:WORawSon,项目名称:VhdAttach,代码行数:31,代码来源:State+[015].cs

示例7: GetSplitterPropertyGrid

        //----------------------------------------------------------------------------
        /// <summary>
        /// Метод возвращат ширину первой колонки PropertyGrid
        /// </summary>
        /// <param name="control">PropertyGrid</param>
        /// <returns>Ширина первой колонки</returns>
        private int GetSplitterPropertyGrid(PropertyGrid control)
        {
            Type type = control.GetType();
            FieldInfo field = type.GetField("gridView",
                BindingFlags.NonPublic | BindingFlags.Instance);

            object valGrid = field.GetValue(control);
            Type gridType = valGrid.GetType();
            int width = (int)gridType.InvokeMember("GetLabelWidth",
                BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Instance,
                null, valGrid, new object[] { });

            //MessageBox.Show(width.ToString());
            
            return width;
        }
开发者ID:serialbus,项目名称:NGK,代码行数:22,代码来源:FormMain.cs

示例8: SetSplitterPropertyGrid

        //----------------------------------------------------------------------------
        /// <summary>
        /// Метод изменяет ширину колонок в контроле PropertyGrid
        /// </summary>
        /// <param name="control">PropertyGrid</param>
        /// <param name="width">Ширина первой колнки</param>
        private void SetSplitterPropertyGrid(PropertyGrid control, int width)
        {
            Type type  = control.GetType();
            
            FieldInfo field = type.GetField("gridView",
                BindingFlags.NonPublic | BindingFlags.Instance);
            
            object valGrid = field.GetValue(control);
            
            Type gridType = valGrid.GetType();

            gridType.InvokeMember("MoveSplitterTo",
                BindingFlags.NonPublic | BindingFlags.InvokeMethod | BindingFlags.Instance,
                null,
                valGrid,
                new object[] {width});

            return;
        }
开发者ID:serialbus,项目名称:NGK,代码行数:25,代码来源:FormMain.cs

示例9: SetLabelColumnWidth

        public static void SetLabelColumnWidth(PropertyGrid grid, int width)
        {
            if (grid == null)
                return;

            FieldInfo fi = grid.GetType().GetField("gridView", BindingFlags.Instance | BindingFlags.NonPublic);
            if (fi == null)
                return;

            Control view = fi.GetValue(grid) as Control;
            if (view == null)
                return;

            MethodInfo mi = view.GetType().GetMethod("MoveSplitterTo", BindingFlags.Instance | BindingFlags.NonPublic);
            if (mi == null)
                return;
            mi.Invoke(view, new object[] { width });
        }
开发者ID:superkhung,项目名称:SingularMod3,代码行数:18,代码来源:ConfigurationForm.cs

示例10: AppErrorDialog


//.........这里部分代码省略.........
            detailsLabel = new LinkLabel();
            detailsLabel.AutoSize = true;
            detailsLabel.Margin = new Padding(7, 6, 10, 10);
            detailsLabel.Padding = new Padding();
            detailsLabel.TabIndex = 11;
            detailsLabel.Text = FL.AppErrorDialogDetails;
            detailsLabel.UseCompatibleTextRendering = false;
            detailsLabel.Visible = CanShowDetails;
            tablePanel.Controls.Add(detailsLabel);
            tablePanel.SetRow(detailsLabel, 3);
            tablePanel.SetColumn(detailsLabel, 0);

            var attr = new TypeConverterAttribute(typeof(ExpandableObjectConverter));
            TypeDescriptor.AddAttributes(typeof(Exception), attr);
            grid = new PropertyGrid();
            grid.Dock = DockStyle.Fill;
            grid.Margin = new Padding(10, 10, 10, 10);
            grid.ToolbarVisible = false;
            grid.HelpVisible = false;
            grid.PropertySort = PropertySort.Alphabetical;
            grid.UseCompatibleTextRendering = false;
            grid.Visible = false;
            tablePanel.Controls.Add(grid);
            tablePanel.SetRow(grid, 4);
            tablePanel.SetColumn(grid, 0);

            bool isGridColumnResized = false;
            grid.Resize += (s, e) =>
            {
                if (!isGridColumnResized)
                {
                    isGridColumnResized = true;
                    // Source: http://stackoverflow.com/a/14475276/143684
                    FieldInfo fi = grid.GetType().GetField("gridView", BindingFlags.Instance | BindingFlags.NonPublic);
                    if (fi != null)
                    {
                        Control view = fi.GetValue(grid) as Control;
                        if (view != null)
                        {
                            MethodInfo mi = view.GetType().GetMethod("MoveSplitterTo", BindingFlags.Instance | BindingFlags.NonPublic);
                            if (mi != null)
                            {
                                mi.Invoke(view, new object[] { 170 });
                            }
                            mi = view.GetType().GetMethod("set_GrayTextColor", BindingFlags.Instance | BindingFlags.NonPublic);
                            if (mi != null)
                            {
                                mi.Invoke(view, new object[] { Color.Black });
                            }
                        }
                    }
                }
            };

            detailsLabel.LinkClicked += (s, e) =>
            {
                detailsLabel.Hide();
                this.Height += 300;
                this.Top -= Math.Min(this.Top - 4, 150);
                tablePanel.RowStyles[4].Height = 350;
                grid.Visible = true;
            };

            buttonsPanel = new TableLayoutPanel();
            buttonsPanel.AutoSize = true;
            buttonsPanel.AutoSizeMode = AutoSizeMode.GrowAndShrink;
开发者ID:modulexcite,项目名称:FieldLog,代码行数:67,代码来源:AppErrorDialog.cs


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