當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。