PropertyGrid 类
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
提供用于浏览对象属性的用户界面。
public ref class PropertyGrid : System::Windows::Forms::ContainerControl, System::Windows::Forms::ComponentModel::Com2Interop::IComPropertyBrowser
public class PropertyGrid : System.Windows.Forms.ContainerControl, System.Windows.Forms.ComponentModel.Com2Interop.IComPropertyBrowser
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Runtime.InteropServices.ComVisible(true)]
public class PropertyGrid : System.Windows.Forms.ContainerControl, System.Windows.Forms.ComponentModel.Com2Interop.IComPropertyBrowser
type PropertyGrid = class
inherit ContainerControl
interface IComPropertyBrowser
interface UnsafeNativeMethods.IPropertyNotifySink
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type PropertyGrid = class
inherit ContainerControl
interface IComPropertyBrowser
interface UnsafeNativeMethods.IPropertyNotifySink
[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type PropertyGrid = class
inherit ContainerControl
interface IComPropertyBrowser
type PropertyGrid = class
inherit ContainerControl
interface IComPropertyBrowser
interface Interop.Ole32.IPropertyNotifySink
type PropertyGrid = class
inherit ContainerControl
interface IComPropertyBrowser
interface IPropertyNotifySink.Interface
Public Class PropertyGrid
Inherits ContainerControl
Implements IComPropertyBrowser
- 继承
- 属性
- 实现
下面的代码示例演示如何创建属性网格并在窗体上设置其位置。 此示例要求有一个带有 的 TextBox 窗体。
public:
[PermissionSetAttribute(SecurityAction::Demand, Name="FullTrust")]
Form1()
{
// The initial constructor code goes here.
PropertyGrid^ propertyGrid1 = gcnew PropertyGrid;
propertyGrid1->CommandsVisibleIfAvailable = true;
propertyGrid1->Location = Point( 10, 20 );
propertyGrid1->Size = System::Drawing::Size( 400, 300 );
propertyGrid1->TabIndex = 1;
propertyGrid1->Text = "Property Grid";
this->Controls->Add( propertyGrid1 );
propertyGrid1->SelectedObject = textBox1;
}
public Form1()
{
// The initial constructor code goes here.
PropertyGrid propertyGrid1 = new PropertyGrid();
propertyGrid1.CommandsVisibleIfAvailable = true;
propertyGrid1.Location = new Point(10, 20);
propertyGrid1.Size = new System.Drawing.Size(400, 300);
propertyGrid1.TabIndex = 1;
propertyGrid1.Text = "Property Grid";
Controls.Add(propertyGrid1);
propertyGrid1.SelectedObject = textBox1;
}
Public Sub New()
' The initial constructor code goes here.
Dim propertyGrid1 As New PropertyGrid()
propertyGrid1.CommandsVisibleIfAvailable = True
propertyGrid1.Location = New Point(10, 20)
propertyGrid1.Size = New System.Drawing.Size(400, 300)
propertyGrid1.TabIndex = 1
propertyGrid1.Text = "Property Grid"
Me.Controls.Add(propertyGrid1)
propertyGrid1.SelectedObject = textBox1
End Sub
若要使用属性网格,请在父控件上创建 类的新实例 PropertyGrid ,并将 设置为 SelectedObject 要显示其属性的对象。
网格中显示的信息是分配对象时属性的快照。 如果 指定对象的 SelectedObject 属性值在运行时在代码中发生更改,则在网格中执行导致网格刷新的操作之前,不会显示新值。
属性网格中的属性选项卡显示为 顶部工具栏上的 PropertyGrid按钮,并且可以根据 中 PropertyTabScope定义的范围而有所不同。
可以使用 LargeButtons 属性来显示大按钮,而不是默认的较小按钮。 大按钮是 32 x 32 像素,而不是标准的 16 x 16 像素。 当 app.config 文件包含以下条目时,会根据系统 DPI 设置调整大按钮和小按钮和属性列表扩展器图标 (加号或减号图标) 的大小:
<appSettings>
<add key="EnableWindowsFormsHighDpiAutoResizing" value="true" />
</appSettings>
控件 PropertyGrid 最初不会显示在开发环境中的工具箱中。 可以将属性网格添加到工具箱,以便将 拖 PropertyGrid 到窗体上。 还可以通过在源代码中添加相应的代码来定义 的 PropertyGrid 实例。
的所有公共属性 SelectedObject 默认显示在 中 PropertyGrid 。 可以通过使用 BrowsableAttribute 修饰属性并将值设置为 false
来隐藏属性,使其不显示在控件中PropertyGrid。 可以通过提供带有 的类别来指定属性显示的类别 CategoryAttribute。 可以使用 为显示在控件DescriptionAttribute底部的属性PropertyGrid提供描述性文本。
Property |
初始化 PropertyGrid 类的新实例。 |
Scroll |
确定 AutoScroll 属性的值。 (继承自 ScrollableControl) |
Scroll |
确定用户是否启用了全窗口拖动。 (继承自 ScrollableControl) |
Scroll |
确定 HScroll 属性的值是否设置为 |
Scroll |
确定用户是否滚动了 ScrollableControl 控件。 (继承自 ScrollableControl) |
Scroll |
确定 VScroll 属性的值是否设置为 |
Accessibility |
获取分配给该控件的 AccessibleObject。 (继承自 Control) |
Accessible |
获取或设置控件的默认操作说明以供具有辅助功能的客户端应用程序使用。 (继承自 Control) |
Accessible |
获取或设置辅助功能客户端应用程序使用的控件说明。 (继承自 Control) |
Accessible |
获取或设置辅助功能客户端应用程序所使用的控件名称。 (继承自 Control) |
Accessible |
获取或设置控件的辅助性角色。 (继承自 Control) |
Active |
获取或设置容器控件上的活动控件。 (继承自 ContainerControl) |
Allow |
获取或设置一个值,该值指示控件是否可以接受用户拖放到它上面的数据。 (继承自 Control) |
Anchor |
获取或设置控件绑定到的容器的边缘并确定控件如何随其父级一起调整大小。 (继承自 Control) |
Auto |
获取或设置控件的设计尺寸。 (继承自 ContainerControl) |
Auto |
获取当前和设计时自动缩放尺寸之间的缩放因子。 (继承自 ContainerControl) |
Auto |
获取或设置控件的自动缩放模式。 (继承自 ContainerControl) |
Auto |
此属性与此类无关。 |
Auto |
获取或设置自动滚动边距的大小。 (继承自 ScrollableControl) |
Auto |
获取或设置自动滚动的最小尺寸。 (继承自 ScrollableControl) |
Auto |
获取或设置一个值,该值指示在 ScrollControlIntoView(Control) 中将控件滚动到何处。 (继承自 Control) |
Auto |
获取或设置自动滚动定位的位置。 (继承自 ScrollableControl) |
Auto |
此属性与此类无关。 (继承自 Control) |
Auto |
获取或设置一个值,该值指示当焦点更改时是否自动验证此容器内的控件。 (继承自 ContainerControl) |
Back |
获取或设置控件的背景色。 |
Background |
此属性与此类无关。 |
Background |
此属性与此类无关。 |
Background |
获取或设置在 ImageLayout 枚举中定义的背景图像布局。 (继承自 Control) |
Binding |
获取或设置控件的 BindingContext。 (继承自 ContainerControl) |
Bottom |
获取控件下边缘与其容器的工作区上边缘之间的距离(以像素为单位)。 (继承自 Control) |
Bounds |
获取或设置控件(包括其非工作区元素)相对于其父控件的大小和位置(以像素为单位)。 (继承自 Control) |
Browsable |
获取或设置与属性网格连接的对象相关联的可浏览特性。 |
Can |
获取一个用以指示是否可以将 ImeMode 属性设置为活动值的值,以启用 IME 支持。 (继承自 ContainerControl) |
Can |
获取一个值,该值指示控件是否可以接收焦点。 (继承自 Control) |
Can |
确定是否可以在控件上引发事件。 (继承自 Control) |
Can |
获取一个值,该值指示是否可以选中控件。 (继承自 Control) |
Can |
获取一个值,用以指示命令窗格对于当前选定对象是否可见。 |
Can |
获取或设置一个值,此值指示特定于操作系统的可视样式标志符号是否用于网格区域中的展开节点。 |
Capture |
获取或设置一个值,该值指示控件是否已捕获鼠标。 (继承自 Control) |
Category |
获取或设置用于类别标题的文本颜色。 |
Category |
获取或设置分隔网格区域中的类别的线条的颜色。 |
Causes |
获取或设置一个值,该值指示控件是否会引起在任何需要在接收焦点时执行验证的控件上执行验证。 (继承自 Control) |
Client |
获取表示控件的工作区的矩形。 (继承自 Control) |
Client |
获取或设置控件的工作区的高度和宽度。 (继承自 Control) |
Commands |
获取或设置可执行命令区中的活动链接的颜色。 |
Commands |
获取或设置作用命令区的背景色。 |
Commands |
获取或设置作用命令区的周边的边框色。 |
Commands |
获取或设置可执行命令区中的不可用链接的颜色。 |
Commands |
获取或设置作用命令区的前景色。 |
Commands |
获取或设置可执行命令区中的链接的颜色。 |
Commands |
获取一个值,用以指示命令窗格是否可见。 |
Commands |
获取或设置一个值,它指示命令窗格对于公开谓词的对象是否可见。 |
Company |
获取包含控件的应用程序的公司名称或创建者。 (继承自 Control) |
Container |
获取包含 IContainer 的 Component。 (继承自 Component) |
Contains |
获取一个值,该值指示控件或它的一个子控件当前是否有输入焦点。 (继承自 Control) |
Context |
获取或设置与控件关联的快捷菜单。 (继承自 Control) |
Context |
获取快捷菜单的默认位置。 |
Context |
获取或设置与此控件关联的 ContextMenuStrip。 (继承自 Control) |
Controls |
此属性与此类无关。 |
Created |
获取一个值,该值指示控件是否已经创建。 (继承自 Control) |
Create |
获取创建控件句柄时所需要的创建参数。 (继承自 ContainerControl) |
Current |
获取屏幕的当前运行时尺寸。 (继承自 ContainerControl) |
Cursor |
获取或设置当鼠标指针位于控件上时显示的光标。 (继承自 Control) |
Data |
为该控件获取数据绑定。 (继承自 Control) |
Data |
获取或设置用于数据绑定的数据上下文。 这是一个环境属性。 (继承自 Control) |
Default |
获取或设置控件的默认光标。 (继承自 Control) |
Default |
获取控件支持的默认输入法编辑器 (IME) 模式。 (继承自 Control) |
Default |
获取控件之间默认指定的间距(以像素为单位)。 (继承自 Control) |
Default |
获取以像素为单位的长度和高度,此长度和高度被指定为控件的默认最大大小。 (继承自 Control) |
Default |
获取以像素为单位的长度和高度,此长度和高度被指定为控件的默认最小大小。 (继承自 Control) |
Default |
获取控件内容的默认内部间距(以像素为单位)。 (继承自 Control) |
Default |
获取控件的默认大小。 |
Default |
获取默认选项卡的类型。 |
Design |
获取一个值,用以指示 Component 当前是否处于设计模式。 (继承自 Component) |
Device |
获取显示当前控件的显示设备的 DPI 值。 (继承自 Control) |
Disabled |
获取或设置网格区域中的禁用文本的前景色。 |
Display |
获取表示控件的虚拟显示区域的矩形。 (继承自 ScrollableControl) |
Disposing |
获取一个值,该值指示 Control 基类是否在释放进程中。 (继承自 Control) |
Dock |
获取或设置哪些控件边框停靠到其父控件并确定控件如何随其父级一起调整大小。 (继承自 Control) |
Dock |
获取控件的所有边缘的停靠边距设置。 (继承自 ScrollableControl) |
Double |
获取或设置一个值,该值指示此控件是否应使用辅助缓冲区重绘其图面,以减少或避免闪烁。 (继承自 Control) |
Draw |
获取或设置一个值,该值指示 PropertyGrid 控件是否使用平面按钮绘制其工具栏。 |
Enabled |
获取或设置一个值,该值指示控件是否可以对用户交互作出响应。 (继承自 Control) |
Events |
获取附加到此 Component 的事件处理程序的列表。 (继承自 Component) |
Focused |
获取一个值,该值指示控件是否有输入焦点。 (继承自 Control) |
Font |
获取或设置控件显示的文字的字体。 (继承自 Control) |
Font |
获取或设置控件的字体的高度。 (继承自 Control) |
Fore |
此属性与此类无关。 |
Handle |
获取控件绑定到的窗口句柄。 (继承自 Control) |
Has |
获取一个值,该值指示控件是否包含一个或多个子控件。 (继承自 Control) |
Height |
获取或设置控件的高度。 (继承自 Control) |
Help |
获取或设置“帮助”区域的背景色。 |
Help |
获取或设置说明窗格有关的边框的颜色。 |
Help |
获取或设置“帮助”区域的前景色。 |
Help |
获取或设置一个值,用以指示帮助文本是否可见。 |
Horizontal |
获取与水平滚动条关联的特征。 (继承自 ScrollableControl) |
HScroll |
获取或设置一个值,该值指示水平滚动条是否可见。 (继承自 ScrollableControl) |
Ime |
获取或设置控件的输入法编辑器 (IME) 模式。 (继承自 Control) |
Ime |
获取或设置控件的 IME 模式。 (继承自 Control) |
Invoke |
获取一个值,该值指示调用方在对控件进行方法调用时是否必须调用 Invoke 方法,因为调用方位于创建控件所在的线程以外的线程中。 (继承自 Control) |
Is |
获取或设置一个值,该值指示控件对辅助功能应用程序是否可见。 (继承自 Control) |
Is |
指示此控件的上级之一是否位于 DesignMode 中。 此属性为只读。 (继承自 Control) |
Is |
获取一个值,该值指示控件是否已经被释放。 (继承自 Control) |
Is |
获取一个值,该值指示控件是否有与它关联的句柄。 (继承自 Control) |
Is |
获取一个值,该值指示此控件是否为镜像控件。 (继承自 Control) |
Large |
获取或设置一个值,用以指示按钮显示为标准按钮还是大按钮。 |
Layout |
获取控件的布局引擎的缓存实例。 (继承自 Control) |
Left |
获取或设置控件左边缘与其容器的工作区左边缘之间的距离(以像素为单位)。 (继承自 Control) |
Line |
获取或设置网格线或边框的颜色。 |
Location |
获取或设置该控件的左上角相对于其容器的左上角的坐标。 (继承自 Control) |
Margin |
获取或设置控件之间的空间。 (继承自 Control) |
Maximum |
获取或设置大小,该大小是 GetPreferredSize(Size) 可以指定的上限。 (继承自 Control) |
Minimum |
获取或设置大小,该大小是 GetPreferredSize(Size) 可以指定的下限。 (继承自 Control) |
Name |
获取或设置控件的名称。 (继承自 Control) |
Padding |
此属性与此类无关。 |
Padding |
获取或设置控件内的空白。 (继承自 Control) |
Parent |
获取或设置控件的父容器。 (继承自 Control) |
Parent |
获取将容器控件分配给的窗体。 (继承自 ContainerControl) |
Preferred |
获取可以容纳控件的矩形区域的大小。 (继承自 Control) |
Product |
获取包含控件的程序集的产品名称。 (继承自 Control) |
Product |
获取包含控件的程序集的版本。 (继承自 Control) |
Property |
获取或设置 PropertyGrid 在显示属性时所采用的排序类型。 |
Property |
获取网格中显示的属性选项卡集合。 |
Recreating |
获取一个值,该值指示控件当前是否在重新创建其句柄。 (继承自 Control) |
Region |
获取或设置与控件关联的窗口区域。 (继承自 Control) |
Render |
已过时.
已过时.
此属性现已过时。 (继承自 Control) |
Resize |
获取或设置一个值,该值指示控件在调整大小时是否重绘自己。 (继承自 Control) |
Right |
获取控件右边缘与其容器的工作区左边缘之间的距离(以像素为单位)。 (继承自 Control) |
Right |
获取或设置一个值,该值指示是否将控件的元素对齐以支持使用从右向左的字体的区域设置。 (继承自 Control) |
Scale |
获取一个值,该值确定子控件的缩放。 (继承自 Control) |
Selected |
获取或设置选定网格项。 |
Selected |
获取或设置拥有输入焦点的选定项的背景色。 |
Selected |
获取或设置拥有输入焦点的选定项的前景色。 |
Selected |
获取或设置在网格中显示属性的对象。 |
Selected |
获取或设置当前选定的对象。 |
Selected |
获取当前选定的属性选项卡。 |
Show |
获取一个值,该值指示控件是否应显示聚焦框。 |
Show |
获取一个值,该值指示用户界面是否处于适当的状态以显示或隐藏键盘快捷键。 (继承自 Control) |
Show |
获取表示属性页的图像。 |
Site |
获取或设置控件的站点。 |
Size |
获取或设置控件的高度和宽度。 (继承自 Control) |
Sort |
获取按类别表示排序网格项的图像。 |
Sort |
获取按属性名表示排序网格项的图像。 |
Tab |
获取或设置控件在其容器内的 Tab 键顺序。 (继承自 Control) |
Tab |
获取或设置一个值,该值指示用户能否使用 Tab 键将焦点放到该控件上。 (继承自 Control) |
Tag |
获取或设置包含有关控件的数据的对象。 (继承自 Control) |
Text |
获取或设置与此控件关联的文本。 |
Text |
获取或设置与此控件关联的文本。 (继承自 Control) |
Toolbar |
获取或设置一个值,用以指示工具栏是否可见。 |
Tool |
获取或设置用于 ToolStrip 对象的绘制功能。 |
Top |
获取或设置控件上边缘与其容器的工作区上边缘之间的距离(以像素为单位)。 (继承自 Control) |
Top |
获取没有另一个 Windows 窗体控件作为其父级的父控件。 通常,这是控件所在的最外面的 Form。 (继承自 Control) |
Use |
获取或设置一个值,该值确定是使用 Graphics 类 (GDI+) 还是 TextRenderer 使用 GDI) 类来呈现文本 (GDI。 |
Use |
获取或设置一个值,该值指示是否将等待光标用于当前控件以及所有子控件。 (继承自 Control) |
Vertical |
获取与垂直滚动条相关联的特性。 (继承自 ScrollableControl) |
View |
获取或设置一个值,用以指示网格的背景色。 |
View |
获取或设置网格区域中有关的边框的颜色。 |
View |
获取或设置一个值,用以指示网格中文本的颜色。 |
Visible |
获取或设置一个值,该值指示是否显示该控件及其所有子控件。 (继承自 Control) |
VScroll |
获取或设置一个值,该值指示垂直滚动条是否可见。 (继承自 ScrollableControl) |
Width |
获取或设置控件的宽度。 (继承自 Control) |
Window |
此属性与此类无关。 (继承自 Control) |
产品 | 版本 |
---|---|
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |