Files
ctbjrj/.agents/skills/sd-enhanced-components/references/winforms-components.md
T

43 KiB
Raw Blame History

Data / Components / Printing 属性手册(工具箱 23 条目,穷尽版)

生成来源同 winforms-controls.md(.NET Framework 4.8 反射全量)。序列化列约定同前;(RO)=只读。

0. 共享基类

  • Component 基类属性(Site/Container/Tag 等)见 winforms-controls.md 第 0 节;本文件各类型的继承行引用同处的基类总表。

Data 分类(7 条目)

BindingNavigator — 数据导航条(ToolStrip 子类,绑定 BindingSource 后自动带首/上/下/末/新增/删除按钮)。Designer 为其生成标准 9 项 Items。

自有属性(10 个):

属性 类型 默认值 序列化 说明
BindingSource BindingSource —
MoveFirstItem ToolStripItem —
MovePreviousItem ToolStripItem —
MoveNextItem ToolStripItem —
MoveLastItem ToolStripItem —
AddNewItem ToolStripItem —
DeleteItem ToolStripItem —
PositionItem ToolStripItem —
CountItem ToolStripItem —
CountItemFormat String —
  • 继承 ToolStrip(43 个):AutoSize, AutoScroll, AutoScrollMargin, AutoScrollMinSize, AutoScrollPosition, AllowDrop, AllowItemReorder, AllowMerge, Anchor, BackColor, BindingContext, CanOverflow, CausesValidation, Controls(RO), Cursor, Font, DefaultDropDownDirection, Dock, DisplayRectangle(RO), ForeColor, GripStyle, GripDisplayStyle(RO), GripMargin, GripRectangle(RO), HasChildren(RO), HorizontalScroll(RO), ImageScalingSize, ImageList, IsCurrentlyDragging(RO), Items(RO), IsDropDown(RO), LayoutSettings, LayoutStyle, LayoutEngine(RO), OverflowButton(RO), Orientation(RO), Stretch, Renderer, RenderMode, ShowItemToolTips, TabStop, TextDirection, VerticalScroll(RO)
  • 继承 ScrollableControl(1 个):DockPadding(RO)
  • 继承 Control(59 个):AccessibilityObject(RO), AccessibleDefaultActionDescription, AccessibleDescription, AccessibleName, AccessibleRole, AutoScrollOffset, BackgroundImage, BackgroundImageLayout, Bottom(RO), Bounds, CanFocus(RO), CanSelect(RO), Capture, ClientRectangle(RO), ClientSize, CompanyName(RO), ContainsFocus(RO), ContextMenu, ContextMenuStrip, Created(RO), DataBindings(RO), DeviceDpi(RO), IsDisposed(RO), Disposing(RO), Enabled, Focused(RO), Handle(RO), Height, IsHandleCreated(RO), InvokeRequired(RO), IsAccessible, IsMirrored(RO), Left, Location, Margin, MaximumSize, MinimumSize, Name, Parent, ProductName(RO), ProductVersion(RO), RecreatingHandle(RO), Region, Right(RO), RightToLeft, Site, Size, TabIndex, Tag, Text, Top, TopLevelControl(RO), UseWaitCursor, Visible, Width, WindowTarget, PreferredSize(RO), Padding, ImeMode
  • 继承 Component(1 个):Container(RO)

自有事件:RefreshItems(EH)

BindingSource — 绑定源组件:DataSource/DataMember 定数据,控件(DataGridView 等)绑它而不是直绑数据集;Position/Sort/Filter 运行时用。

自有属性(27 个):

属性 类型 默认值 序列化 说明
CurrencyManager(RO) CurrencyManager 不序列化
Current(RO) Object 不序列化
DataMember String —
DataSource Object —
IsBindingSuspended(RO) Boolean 不序列化
List(RO) IList 不序列化
Position Int32 -1 不序列化
RaiseListChangedEvents Boolean True 不序列化
Sort String —
Count(RO) Int32 不序列化
IsSynchronized(RO) Boolean 不序列化
SyncRoot(RO) Object 不序列化
IsFixedSize(RO) Boolean 不序列化
IsReadOnly(RO) Boolean 不序列化
AllowEdit(RO) Boolean 不序列化
AllowNew Boolean —
AllowRemove(RO) Boolean 不序列化
SupportsChangeNotification(RO) Boolean 不序列化
SupportsSearching(RO) Boolean 不序列化
SupportsSorting(RO) Boolean 不序列化
IsSorted(RO) Boolean 不序列化
SortProperty(RO) PropertyDescriptor 不序列化
SortDirection(RO) ListSortDirection 不序列化
SortDescriptions(RO) ListSortDescriptionCollection 不序列化
Filter String —
SupportsAdvancedSorting(RO) Boolean 不序列化
SupportsFiltering(RO) Boolean 不序列化
  • 继承 Component(2 个):Site, Container(RO)

自有事件:AddingNew(AddingNewEH);BindingComplete(BindingCompleteEH);DataError(BindingManagerDataErrorEH);DataSourceChanged(EH);DataMemberChanged(EH);CurrentChanged(EH);CurrentItemChanged(EH);ListChanged(ListChangedEH);PositionChanged(EH)

DataNavigator

⚠️ 该类型在 .NET Framework 4.8 中不存在(System.Windows.Forms.DataNavigator 无此公共类型,反射确认)。 工具箱 sdcl 里的这条目是死条目:拖放会失败。数据导航一律用 BindingNavigator。

DataGrid — 旧版数据网格(已过时,新项目用 DataGridView 或 EnhancedDataGridView)。

自有属性(45 个):

属性 类型 默认值 序列化 说明
AllowSorting Boolean True 非默认才写
AlternatingBackColor Color —
BackColor Color —
ForeColor Color —
BorderStyle BorderStyle Fixed3D 非默认才写
CaptionBackColor Color —
CaptionForeColor Color —
CaptionFont Font —
CaptionText String —
CaptionVisible Boolean True 非默认才写
CurrentCell DataGridCell 不序列化
SelectionBackColor Color —
SelectionForeColor Color —
DataSource Object —
DataMember String —
CurrentRowIndex Int32 不序列化
TableStyles(RO) GridTableStylesCollection Content 集合
GridLineColor Color —
GridLineStyle DataGridLineStyle Solid 非默认才写
ParentRowsLabelStyle DataGridParentRowsLabelStyle Both 不序列化
FirstVisibleColumn(RO) Int32 不序列化
FlatMode Boolean False 非默认才写
HeaderBackColor Color —
BackgroundColor Color —
HeaderFont Font —
HeaderForeColor Color —
LinkColor Color —
LinkHoverColor Color 不序列化
AllowNavigation Boolean True 非默认才写
Cursor Cursor 不序列化
BackgroundImage Image 不序列化
BackgroundImageLayout ImageLayout 不序列化
ParentRowsBackColor Color —
ParentRowsForeColor Color —
PreferredColumnWidth Int32 75 非默认才写
PreferredRowHeight Int32 —
ReadOnly Boolean False 非默认才写
ColumnHeadersVisible Boolean True 非默认才写
ParentRowsVisible Boolean True 非默认才写
RowHeadersVisible Boolean True 非默认才写
RowHeaderWidth Int32 35 非默认才写
Text String 不序列化
VisibleColumnCount(RO) Int32 不序列化
VisibleRowCount(RO) Int32 不序列化
Site ISite —
  • 继承 Control(67 个):AccessibilityObject(RO), AccessibleDefaultActionDescription, AccessibleDescription, AccessibleName, AccessibleRole, AllowDrop, Anchor, AutoSize, AutoScrollOffset, LayoutEngine(RO), BindingContext, Bottom(RO), Bounds, CanFocus(RO), CanSelect(RO), Capture, CausesValidation, ClientRectangle(RO), ClientSize, CompanyName(RO), ContainsFocus(RO), ContextMenu, ContextMenuStrip, Controls(RO), Created(RO), DataBindings(RO), DeviceDpi(RO), DisplayRectangle(RO), IsDisposed(RO), Disposing(RO), Dock, Enabled, Focused(RO), Font, Handle(RO), HasChildren(RO), Height, IsHandleCreated(RO), InvokeRequired(RO), IsAccessible, IsMirrored(RO), Left, Location, Margin, MaximumSize, MinimumSize, Name, Parent, ProductName(RO), ProductVersion(RO), RecreatingHandle(RO), Region, Right(RO), RightToLeft, Size, TabIndex, TabStop, Tag, Top, TopLevelControl(RO), UseWaitCursor, Visible, Width, WindowTarget, PreferredSize(RO), Padding, ImeMode
  • 继承 Component(1 个):Container(RO)

自有事件:BorderStyleChanged(EH);CaptionVisibleChanged(EH);CurrentCellChanged(EH);DataSourceChanged(EH);ParentRowsLabelStyleChanged(EH);FlatModeChanged(EH);BackgroundColorChanged(EH);AllowNavigationChanged(EH);CursorChanged(EH);BackgroundImageChanged(EH);BackgroundImageLayoutChanged(EH);ReadOnlyChanged(EH);ParentRowsVisibleChanged(EH);TextChanged(EH);Navigate(NavigateEH);Scroll(EH);BackButtonClick(EH);ShowParentDetailsButtonClick(EH)

DataGridView — 标准数据网格(增强版见增强组件 EnhancedDataGridView)。Columns 为 Content 集合(DataGridViewTextBoxColumn/DataGridViewComboBoxColumn 等逐列生成)。

自有属性(80 个):

属性 类型 默认值 序列化 说明
AdjustedTopLeftHeaderBorderStyle(RO) DataGridViewAdvancedBorderStyle 不序列化
AdvancedCellBorderStyle(RO) DataGridViewAdvancedBorderStyle 不序列化
AdvancedColumnHeadersBorderStyle(RO) DataGridViewAdvancedBorderStyle 不序列化
AdvancedRowHeadersBorderStyle(RO) DataGridViewAdvancedBorderStyle 不序列化
AllowUserToAddRows Boolean True 非默认才写
AllowUserToDeleteRows Boolean True 非默认才写
AllowUserToOrderColumns Boolean False 非默认才写
AllowUserToResizeColumns Boolean True 非默认才写
AllowUserToResizeRows Boolean True 非默认才写
AlternatingRowsDefaultCellStyle DataGridViewCellStyle —
AutoGenerateColumns Boolean True 不序列化
AutoSize Boolean —
AutoSizeColumnsMode DataGridViewAutoSizeColumnsMode None 非默认才写
AutoSizeRowsMode DataGridViewAutoSizeRowsMode None 非默认才写
BackColor Color 不序列化
BackgroundColor Color —
BackgroundImage Image 不序列化
BackgroundImageLayout ImageLayout 不序列化
BorderStyle BorderStyle FixedSingle 非默认才写
CellBorderStyle DataGridViewCellBorderStyle Single 非默认才写
ClipboardCopyMode DataGridViewClipboardCopyMode EnableWithAutoHeaderText 非默认才写
ColumnCount Int32 0 不序列化
ColumnHeadersBorderStyle DataGridViewHeaderBorderStyle Raised 非默认才写
ColumnHeadersDefaultCellStyle DataGridViewCellStyle —
ColumnHeadersHeight Int32 —
ColumnHeadersHeightSizeMode DataGridViewColumnHeadersHeightSizeMode EnableResizing 非默认才写
ColumnHeadersVisible Boolean True 非默认才写
Columns(RO) DataGridViewColumnCollection Content 集合
CurrentCell DataGridViewCell 不序列化
CurrentCellAddress(RO) Point 不序列化
CurrentRow(RO) DataGridViewRow 不序列化
DataMember String —
DataSource Object —
DefaultCellStyle DataGridViewCellStyle —
DisplayRectangle(RO) Rectangle —
EditMode DataGridViewEditMode EditOnKeystrokeOrF2 非默认才写
EditingControl(RO) Control 不序列化
EditingPanel(RO) Panel 不序列化
EnableHeadersVisualStyles Boolean True 非默认才写
FirstDisplayedCell DataGridViewCell 不序列化
FirstDisplayedScrollingColumnHiddenWidth(RO) Int32 不序列化
FirstDisplayedScrollingColumnIndex Int32 不序列化
FirstDisplayedScrollingRowIndex Int32 不序列化
ForeColor Color 不序列化
Font Font 不序列化
GridColor Color —
HorizontalScrollingOffset Int32 不序列化
IsCurrentCellDirty(RO) Boolean 不序列化
IsCurrentCellInEditMode(RO) Boolean 不序列化
IsCurrentRowDirty(RO) Boolean 不序列化
MultiSelect Boolean True 非默认才写
NewRowIndex(RO) Int32 不序列化
Padding Padding 不序列化
ReadOnly Boolean False 非默认才写
RowCount Int32 0 不序列化
RowHeadersBorderStyle DataGridViewHeaderBorderStyle Raised 非默认才写
RowHeadersDefaultCellStyle DataGridViewCellStyle —
RowHeadersVisible Boolean True 非默认才写
RowHeadersWidth Int32 —
RowHeadersWidthSizeMode DataGridViewRowHeadersWidthSizeMode EnableResizing 非默认才写
Rows(RO) DataGridViewRowCollection 不序列化
RowsDefaultCellStyle DataGridViewCellStyle —
RowTemplate DataGridViewRow Content 集合
ScrollBars ScrollBars Both 非默认才写
SelectedCells(RO) DataGridViewSelectedCellCollection 不序列化
SelectedColumns(RO) DataGridViewSelectedColumnCollection 不序列化
SelectedRows(RO) DataGridViewSelectedRowCollection 不序列化
SelectionMode DataGridViewSelectionMode RowHeaderSelect 非默认才写
ShowCellErrors Boolean True 非默认才写
ShowCellToolTips Boolean True 非默认才写
ShowEditingIcon Boolean True 非默认才写
ShowRowErrors Boolean True 非默认才写
SortedColumn(RO) DataGridViewColumn 不序列化
SortOrder(RO) SortOrder 不序列化
StandardTab Boolean False 非默认才写
Text String 不序列化
TopLeftHeaderCell DataGridViewHeaderCell 不序列化
UserSetCursor(RO) Cursor 不序列化
VerticalScrollingOffset(RO) Int32 不序列化
VirtualMode Boolean False 非默认才写
  • 继承 Control(65 个):AccessibilityObject(RO), AccessibleDefaultActionDescription, AccessibleDescription, AccessibleName, AccessibleRole, AllowDrop, Anchor, AutoScrollOffset, LayoutEngine(RO), BindingContext, Bottom(RO), Bounds, CanFocus(RO), CanSelect(RO), Capture, CausesValidation, ClientRectangle(RO), ClientSize, CompanyName(RO), ContainsFocus(RO), ContextMenu, ContextMenuStrip, Controls(RO), Created(RO), Cursor, DataBindings(RO), DeviceDpi(RO), IsDisposed(RO), Disposing(RO), Dock, Enabled, Focused(RO), Handle(RO), HasChildren(RO), Height, IsHandleCreated(RO), InvokeRequired(RO), IsAccessible, IsMirrored(RO), Left, Location, Margin, MaximumSize, MinimumSize, Name, Parent, ProductName(RO), ProductVersion(RO), RecreatingHandle(RO), Region, Right(RO), RightToLeft, Site, Size, TabIndex, TabStop, Tag, Top, TopLevelControl(RO), UseWaitCursor, Visible, Width, WindowTarget, PreferredSize(RO), ImeMode
  • 继承 Component(1 个):Container(RO)

自有事件:AllowUserToAddRowsChanged(EH);AllowUserToDeleteRowsChanged(EH);AllowUserToOrderColumnsChanged(EH);AllowUserToResizeColumnsChanged(EH);AllowUserToResizeRowsChanged(EH);AlternatingRowsDefaultCellStyleChanged(EH);AutoGenerateColumnsChanged(EH);AutoSizeColumnsModeChanged(DataGridViewAutoSizeColumnsModeEH);AutoSizeRowsModeChanged(DataGridViewAutoSizeModeEH);BackColorChanged(EH);BackgroundColorChanged(EH);BackgroundImageChanged(EH);BackgroundImageLayoutChanged(EH);BorderStyleChanged(EH);CellBorderStyleChanged(EH);ColumnHeadersBorderStyleChanged(EH);ColumnHeadersDefaultCellStyleChanged(EH);ColumnHeadersHeightChanged(EH);ColumnHeadersHeightSizeModeChanged(DataGridViewAutoSizeModeEH);DataMemberChanged(EH);DataSourceChanged(EH);DefaultCellStyleChanged(EH);EditModeChanged(EH);ForeColorChanged(EH);FontChanged(EH);GridColorChanged(EH);MultiSelectChanged(EH);PaddingChanged(EH);ReadOnlyChanged(EH);RowHeadersBorderStyleChanged(EH);RowHeadersDefaultCellStyleChanged(EH);RowHeadersWidthChanged(EH);RowHeadersWidthSizeModeChanged(DataGridViewAutoSizeModeEH);RowsDefaultCellStyleChanged(EH);TextChanged(EH);AutoSizeColumnModeChanged(DataGridViewAutoSizeColumnModeEH);CancelRowEdit(QuestionEH);CellBeginEdit(DataGridViewCellCancelEH);CellClick(DataGridViewCellEH);CellContentClick(DataGridViewCellEH);CellContentDoubleClick(DataGridViewCellEH);CellContextMenuStripChanged(DataGridViewCellEH);CellContextMenuStripNeeded(DataGridViewCellContextMenuStripNeededEH);CellDoubleClick(DataGridViewCellEH);CellEndEdit(DataGridViewCellEH);CellEnter(DataGridViewCellEH);CellErrorTextChanged(DataGridViewCellEH);CellErrorTextNeeded(DataGridViewCellErrorTextNeededEH);CellFormatting(DataGridViewCellFormattingEH);CellLeave(DataGridViewCellEH);CellMouseClick(DataGridViewCellMouseEH);CellMouseDoubleClick(DataGridViewCellMouseEH);CellMouseDown(DataGridViewCellMouseEH);CellMouseEnter(DataGridViewCellEH);CellMouseLeave(DataGridViewCellEH);CellMouseMove(DataGridViewCellMouseEH);CellMouseUp(DataGridViewCellMouseEH);CellPainting(DataGridViewCellPaintingEH);CellParsing(DataGridViewCellParsingEH);CellStateChanged(DataGridViewCellStateChangedEH);CellStyleChanged(DataGridViewCellEH);CellStyleContentChanged(DataGridViewCellStyleContentChangedEH);CellToolTipTextChanged(DataGridViewCellEH);CellToolTipTextNeeded(DataGridViewCellToolTipTextNeededEH);CellValidated(DataGridViewCellEH);CellValidating(DataGridViewCellValidatingEH);CellValueChanged(DataGridViewCellEH);CellValueNeeded(DataGridViewCellValueEH);CellValuePushed(DataGridViewCellValueEH);ColumnAdded(DataGridViewColumnEH);ColumnContextMenuStripChanged(DataGridViewColumnEH);ColumnDataPropertyNameChanged(DataGridViewColumnEH);ColumnDefaultCellStyleChanged(DataGridViewColumnEH);ColumnDisplayIndexChanged(DataGridViewColumnEH);ColumnDividerDoubleClick(DataGridViewColumnDividerDoubleClickEH);ColumnDividerWidthChanged(DataGridViewColumnEH);ColumnHeaderMouseClick(DataGridViewCellMouseEH);ColumnHeaderMouseDoubleClick(DataGridViewCellMouseEH);ColumnHeaderCellChanged(DataGridViewColumnEH);ColumnMinimumWidthChanged(DataGridViewColumnEH);ColumnNameChanged(DataGridViewColumnEH);ColumnRemoved(DataGridViewColumnEH);ColumnSortModeChanged(DataGridViewColumnEH);ColumnStateChanged(DataGridViewColumnStateChangedEH);ColumnToolTipTextChanged(DataGridViewColumnEH);ColumnWidthChanged(DataGridViewColumnEH);CurrentCellChanged(EH);CurrentCellDirtyStateChanged(EH);DataBindingComplete(DataGridViewBindingCompleteEH);DataError(DataGridViewDataErrorEH);DefaultValuesNeeded(DataGridViewRowEH);EditingControlShowing(DataGridViewEditingControlShowingEH);NewRowNeeded(DataGridViewRowEH);RowContextMenuStripChanged(DataGridViewRowEH);RowContextMenuStripNeeded(DataGridViewRowContextMenuStripNeededEH);RowDefaultCellStyleChanged(DataGridViewRowEH);RowDirtyStateNeeded(QuestionEH);RowDividerDoubleClick(DataGridViewRowDividerDoubleClickEH);RowDividerHeightChanged(DataGridViewRowEH);RowEnter(DataGridViewCellEH);RowErrorTextChanged(DataGridViewRowEH);RowErrorTextNeeded(DataGridViewRowErrorTextNeededEH);RowHeaderMouseClick(DataGridViewCellMouseEH);RowHeaderMouseDoubleClick(DataGridViewCellMouseEH);RowHeaderCellChanged(DataGridViewRowEH);RowHeightChanged(DataGridViewRowEH);RowHeightInfoNeeded(DataGridViewRowHeightInfoNeededEH);RowHeightInfoPushed(DataGridViewRowHeightInfoPushedEH);RowLeave(DataGridViewCellEH);RowMinimumHeightChanged(DataGridViewRowEH);RowPostPaint(DataGridViewRowPostPaintEH);RowPrePaint(DataGridViewRowPrePaintEH);RowsAdded(DataGridViewRowsAddedEH);RowsRemoved(DataGridViewRowsRemovedEH);RowStateChanged(DataGridViewRowStateChangedEH);RowUnshared(DataGridViewRowEH);RowValidated(DataGridViewCellEH);RowValidating(DataGridViewCellCancelEH);Scroll(ScrollEH);SelectionChanged(EH);SortCompare(DataGridViewSortCompareEH);Sorted(EH);StyleChanged(EH);UserAddedRow(DataGridViewRowEH);UserDeletedRow(DataGridViewRowEH);UserDeletingRow(DataGridViewRowCancelEH)

DataSet — 数据集组件;Tables/Relations Content 集合(通常代码生成/设计器向导生成 XML schema)。

自有属性(15 个):

属性 类型 默认值 序列化 说明
RemotingFormat SerializationFormat Xml 非默认才写
SchemaSerializationMode SchemaSerializationMode 不序列化
CaseSensitive Boolean False 非默认才写
DefaultViewManager(RO) DataViewManager 不序列化
EnforceConstraints Boolean True 非默认才写
DataSetName String —
Namespace String —
Prefix String —
ExtendedProperties(RO) PropertyCollection 不序列化
HasErrors(RO) Boolean 不序列化
IsInitialized(RO) Boolean 不序列化
Locale CultureInfo —
Site ISite 不序列化
Relations(RO) DataRelationCollection Content 集合
Tables(RO) DataTableCollection Content 集合
  • 继承 MarshalByValueComponent(2 个):Container(RO), DesignMode(RO)

自有事件:MergeFailed(MergeFailedEH);Initialized(EH)

DataView — 数据视图组件;Table/Sort/RowFilter 配置。

自有属性(11 个):

属性 类型 默认值 序列化 说明
AllowDelete Boolean True 非默认才写
ApplyDefaultSort Boolean False 非默认才写
AllowEdit Boolean True 非默认才写
AllowNew Boolean True 非默认才写
Count(RO) Int32 不序列化
DataViewManager(RO) DataViewManager 不序列化
IsInitialized(RO) Boolean 不序列化
RowFilter String —
RowStateFilter DataViewRowState CurrentRows 非默认才写
Sort String —
Table DataTable —
  • 继承 MarshalByValueComponent(3 个):Site, Container(RO), DesignMode(RO)

自有事件:ListChanged(ListChangedEH);Initialized(EH)


Components 分类(11 条目)

BackgroundWorker — 后台线程组件:DoWork 里干活(不可碰 UI),ReportProgress→ProgressChanged(UI 线程),完成→RunWorkerCompleted。WorkerReportsProgress/WorkerSupportsCancellation 先开。

自有属性(4 个):

属性 类型 默认值 序列化 说明
CancellationPending(RO) Boolean 不序列化
IsBusy(RO) Boolean 不序列化
WorkerReportsProgress Boolean False 非默认才写
WorkerSupportsCancellation Boolean False 非默认才写
  • 继承 Component(2 个):Site, Container(RO)

自有事件:DoWork(DoWorkEH);ProgressChanged(ProgressChangedEH);RunWorkerCompleted(RunWorkerCompletedEH)

ErrorProvider — 见 winforms-controls.md(同组件,两分类都有)。

自有属性(9 个):

属性 类型 默认值 序列化 说明
Site ISite —
BlinkStyle ErrorBlinkStyle BlinkIfDifferentError 非默认才写
ContainerControl ContainerControl —
RightToLeft Boolean False 非默认才写
Tag Object —
DataSource Object —
DataMember String —
BlinkRate Int32 250 非默认才写
Icon Icon —
  • 继承 Component(1 个):Container(RO)

自有事件:RightToLeftChanged(EH)

EventLog — Windows 事件日志:Log/Source/MachineName;EnableRaisingEvents+EntryWritten 监听。写入需权限。

自有属性(10 个):

属性 类型 默认值 序列化 说明
Entries(RO) EventLogEntryCollection 不序列化
LogDisplayName(RO) String 不序列化
Log String —
MachineName String . 非默认才写
MaximumKilobytes Int64 不序列化
OverflowAction(RO) OverflowAction 不序列化
MinimumRetentionDays(RO) Int32 不序列化
EnableRaisingEvents Boolean False 不序列化
SynchronizingObject ISynchronizeInvoke 不序列化
Source String —
  • 继承 Component(2 个):Site, Container(RO)

自有事件:EntryWritten(EntryWrittenEH)

FileSystemWatcher — 文件系统监视:Path/Filter/NotifyFilter+IncludeSubdirectories;Created/Changed/Deleted/Renamed/Error 事件;EnableRaisingEvents=true 才开始。

自有属性(8 个):

属性 类型 默认值 序列化 说明
NotifyFilter NotifyFilters FileName, DirectoryName, LastWrite 非默认才写
EnableRaisingEvents Boolean False 非默认才写
Filter String . 非默认才写
IncludeSubdirectories Boolean False 非默认才写
InternalBufferSize Int32 8192 不序列化
Path String —
Site ISite 不序列化
SynchronizingObject ISynchronizeInvoke 不序列化
  • 继承 Component(1 个):Container(RO)

自有事件:Changed(FileSystemEH);Created(FileSystemEH);Deleted(FileSystemEH);Error(ErrorEH);Renamed(RenamedEH)

HelpProvider — 见 winforms-controls.md。

自有属性(2 个):

属性 类型 默认值 序列化 说明
HelpNamespace String —
Tag Object —
  • 继承 Component(2 个):Site, Container(RO)

自有事件:无。

ImageList — 见 winforms-controls.md。

自有属性(8 个):

属性 类型 默认值 序列化 说明
ColorDepth ColorDepth —
Handle(RO) IntPtr 不序列化
HandleCreated(RO) Boolean 不序列化
Images(RO) ImageCollection 不序列化
ImageSize Size —
ImageStream ImageListStreamer 不序列化
Tag Object —
TransparentColor Color —
  • 继承 Component(2 个):Site, Container(RO)

自有事件:RecreateHandle(EH)

NotifyIcon — 托盘图标:Icon 必须(否则不可见)、Visible、ContextMenuStrip、BalloonTip*;MouseDoubleClick 常用于还原主窗体。

自有属性(9 个):

属性 类型 默认值 序列化 说明
BalloonTipText String —
BalloonTipIcon ToolTipIcon None 非默认才写
BalloonTipTitle String —
ContextMenu ContextMenu 不序列化
ContextMenuStrip ContextMenuStrip —
Icon Icon —
Text String —
Visible Boolean False 非默认才写
Tag Object —
  • 继承 Component(2 个):Site, Container(RO)

自有事件:BalloonTipClicked(EH);BalloonTipClosed(EH);BalloonTipShown(EH);Click(EH);DoubleClick(EH);MouseClick(MouseEH);MouseDoubleClick(MouseEH);MouseDown(MouseEH);MouseMove(MouseEH);MouseUp(MouseEH)

PerformanceCounter — 性能计数器:CategoryName/CounterName/InstanceName;ReadOnly=false 才能写 RawValue。

自有属性(9 个):

属性 类型 默认值 序列化 说明
CategoryName String —
CounterHelp(RO) String 不序列化
CounterName String —
CounterType(RO) PerformanceCounterType 不序列化
InstanceLifetime PerformanceCounterInstanceLifetime Global 非默认才写
InstanceName String —
ReadOnly Boolean True 不序列化
MachineName String . 不序列化
RawValue Int64 不序列化
  • 继承 Component(2 个):Site, Container(RO)

自有事件:无。

Process — 进程组件:StartInfo(Content:FileName/Arguments/UseShellExecute/…)配置后 Start();Exited 配 EnableRaisingEvents。

自有属性(50 个):

属性 类型 默认值 序列化 说明
BasePriority(RO) Int32 不序列化
ExitCode(RO) Int32 不序列化
HasExited(RO) Boolean 不序列化
ExitTime(RO) DateTime 不序列化
Handle(RO) IntPtr 不序列化
SafeHandle(RO) SafeProcessHandle 不序列化
HandleCount(RO) Int32 不序列化
Id(RO) Int32 不序列化
MachineName(RO) String 不序列化
MainWindowHandle(RO) IntPtr 不序列化
MainWindowTitle(RO) String 不序列化
MainModule(RO) ProcessModule 不序列化
MaxWorkingSet IntPtr 不序列化
MinWorkingSet IntPtr 不序列化
Modules(RO) ProcessModuleCollection 不序列化
NonpagedSystemMemorySize(RO) Int32 不序列化
NonpagedSystemMemorySize64(RO) Int64 不序列化
PagedMemorySize(RO) Int32 不序列化
PagedMemorySize64(RO) Int64 不序列化
PagedSystemMemorySize(RO) Int32 不序列化
PagedSystemMemorySize64(RO) Int64 不序列化
PeakPagedMemorySize(RO) Int32 不序列化
PeakPagedMemorySize64(RO) Int64 不序列化
PeakWorkingSet(RO) Int32 不序列化
PeakWorkingSet64(RO) Int64 不序列化
PeakVirtualMemorySize(RO) Int32 不序列化
PeakVirtualMemorySize64(RO) Int64 不序列化
PriorityBoostEnabled Boolean 不序列化
PriorityClass ProcessPriorityClass 不序列化
PrivateMemorySize(RO) Int32 不序列化
PrivateMemorySize64(RO) Int64 不序列化
PrivilegedProcessorTime(RO) TimeSpan 不序列化
ProcessName(RO) String 不序列化
ProcessorAffinity IntPtr 不序列化
Responding(RO) Boolean 不序列化
SessionId(RO) Int32 不序列化
StartInfo ProcessStartInfo 不序列化
StartTime(RO) DateTime 不序列化
SynchronizingObject ISynchronizeInvoke 不序列化
Threads(RO) ProcessThreadCollection 不序列化
TotalProcessorTime(RO) TimeSpan 不序列化
UserProcessorTime(RO) TimeSpan 不序列化
VirtualMemorySize(RO) Int32 不序列化
VirtualMemorySize64(RO) Int64 不序列化
EnableRaisingEvents Boolean False 不序列化
StandardInput(RO) StreamWriter 不序列化
StandardOutput(RO) StreamReader 不序列化
StandardError(RO) StreamReader 不序列化
WorkingSet(RO) Int32 不序列化
WorkingSet64(RO) Int64 不序列化
  • 继承 Component(2 个):Site, Container(RO)

自有事件:OutputDataReceived(DataReceivedEH);ErrorDataReceived(DataReceivedEH);Exited(EH)

SerialPort — 串口:PortName/BaudRate(9600)/DataBits(8)/Parity(None)/StopBits(One)/Handshake;DataReceived 事件读、Write 写;x86 项目才稳(部分驱动 64 位问题)。

自有属性(25 个):

属性 类型 默认值 序列化 说明
BaseStream(RO) Stream 不序列化
BaudRate Int32 9600 非默认才写
BreakState Boolean 不序列化
BytesToWrite(RO) Int32 不序列化
BytesToRead(RO) Int32 不序列化
CDHolding(RO) Boolean 不序列化
CtsHolding(RO) Boolean 不序列化
DataBits Int32 8 非默认才写
DiscardNull Boolean False 非默认才写
DsrHolding(RO) Boolean 不序列化
DtrEnable Boolean False 非默认才写
Encoding Encoding 不序列化
Handshake Handshake None 非默认才写
IsOpen(RO) Boolean 不序列化
NewLine String —
Parity Parity None 非默认才写
ParityReplace Byte 63 非默认才写
PortName String COM1 非默认才写
ReadBufferSize Int32 4096 非默认才写
ReadTimeout Int32 -1 非默认才写
ReceivedBytesThreshold Int32 1 非默认才写
RtsEnable Boolean False 非默认才写
StopBits StopBits One 非默认才写
WriteBufferSize Int32 2048 非默认才写
WriteTimeout Int32 -1 非默认才写
  • 继承 Component(2 个):Site, Container(RO)

自有事件:ErrorReceived(SerialErrorReceivedEH);PinChanged(SerialPinChangedEH);DataReceived(SerialDataReceivedEH)

Timer — 见 winforms-controls.md(System.Windows.Forms.Timer,注意别和 System.Timers.Timer 混淆)。

自有属性(3 个):

属性 类型 默认值 序列化 说明
Tag Object —
Enabled Boolean False 非默认才写
Interval Int32 100 非默认才写
  • 继承 Component(2 个):Site, Container(RO)

自有事件:Tick(EH)


Printing 分类(5 条目)

PageSetupDialog — 页面设置对话框:Document 或 PageSettings/PrinterSettings 二选一关联。

自有属性(11 个):

属性 类型 默认值 序列化 说明
AllowMargins Boolean True 非默认才写
AllowOrientation Boolean True 非默认才写
AllowPaper Boolean True 非默认才写
AllowPrinter Boolean True 非默认才写
Document PrintDocument —
EnableMetric Boolean False 非默认才写
MinMargins Margins —
PageSettings PageSettings 不序列化
PrinterSettings PrinterSettings 不序列化
ShowHelp Boolean False 非默认才写
ShowNetwork Boolean True 非默认才写
  • 继承 CommonDialog(1 个):Tag
  • 继承 Component(2 个):Site, Container(RO)

自有事件:无。

PrintDialog — 打印对话框:Document 关联;AllowSomePages/AllowSelection 开范围选择;PrinterSettings 运行时读写。

自有属性(10 个):

属性 类型 默认值 序列化 说明
AllowCurrentPage Boolean False 非默认才写
AllowSomePages Boolean False 非默认才写
AllowPrintToFile Boolean True 非默认才写
AllowSelection Boolean False 非默认才写
Document PrintDocument —
PrinterSettings PrinterSettings 不序列化
PrintToFile Boolean False 非默认才写
ShowHelp Boolean False 非默认才写
ShowNetwork Boolean True 非默认才写
UseEXDialog Boolean False 非默认才写
  • 继承 CommonDialog(1 个):Tag
  • 继承 Component(2 个):Site, Container(RO)

自有事件:无。

PrintDocument — 打印文档核心:PrintPage 事件里 e.Graphics 画内容、e.HasMorePages 控制翻页;BeginPrint/EndPrint/QueryPageSettings。DocumentName 默认 document。

自有属性(5 个):

属性 类型 默认值 序列化 说明
DefaultPageSettings PageSettings 不序列化
DocumentName String document 非默认才写
OriginAtMargins Boolean False 非默认才写
PrintController PrintController 不序列化
PrinterSettings PrinterSettings 不序列化
  • 继承 Component(2 个):Site, Container(RO)

自有事件:BeginPrint(PrintEH);EndPrint(PrintEH);PrintPage(PrintPageEH);QueryPageSettings(QueryPageSettingsEH)

PrintPreviewControl — 打印预览裸控件:Document 关联即渲染;Zoom/AutoZoom/Columns/Rows 布局。

自有属性(9 个):

属性 类型 默认值 序列化 说明
UseAntiAlias Boolean False 非默认才写
AutoZoom Boolean True 非默认才写
Document PrintDocument —
Columns Int32 1 非默认才写
Rows Int32 1 非默认才写
RightToLeft RightToLeft —
Text String 不序列化
StartPage Int32 0 非默认才写
Zoom Double 0.3 非默认才写
  • 继承 Control(72 个):AccessibilityObject(RO), AccessibleDefaultActionDescription, AccessibleDescription, AccessibleName, AccessibleRole, AllowDrop, Anchor, AutoSize, AutoScrollOffset, LayoutEngine(RO), BackColor, BackgroundImage, BackgroundImageLayout, BindingContext, Bottom(RO), Bounds, CanFocus(RO), CanSelect(RO), Capture, CausesValidation, ClientRectangle(RO), ClientSize, CompanyName(RO), ContainsFocus(RO), ContextMenu, ContextMenuStrip, Controls(RO), Created(RO), Cursor, DataBindings(RO), DeviceDpi(RO), DisplayRectangle(RO), IsDisposed(RO), Disposing(RO), Dock, Enabled, Focused(RO), Font, ForeColor, Handle(RO), HasChildren(RO), Height, IsHandleCreated(RO), InvokeRequired(RO), IsAccessible, IsMirrored(RO), Left, Location, Margin, MaximumSize, MinimumSize, Name, Parent, ProductName(RO), ProductVersion(RO), RecreatingHandle(RO), Region, Right(RO), Site, Size, TabIndex, TabStop, Tag, Top, TopLevelControl(RO), UseWaitCursor, Visible, Width, WindowTarget, PreferredSize(RO), Padding, ImeMode
  • 继承 Component(1 个):Container(RO)

自有事件:TextChanged(EH);StartPageChanged(EH)

PrintPreviewDialog — 打印预览对话框(内含 PrintPreviewControl 的 Form):Document 关联后 ShowDialog()。

自有属性(60 个):

属性 类型 默认值 序列化 说明
AcceptButton IButtonControl 不序列化
AutoScale Boolean 不序列化
AutoScroll Boolean 不序列化
AutoSize Boolean 不序列化
AutoValidate AutoValidate 不序列化
BackColor Color 不序列化
CancelButton IButtonControl 不序列化
ControlBox Boolean 不序列化
ContextMenuStrip ContextMenuStrip 不序列化
FormBorderStyle FormBorderStyle 不序列化
HelpButton Boolean 不序列化
Icon Icon 不序列化
IsMdiContainer Boolean 不序列化
KeyPreview Boolean 不序列化
MaximumSize Size 不序列化
MaximizeBox Boolean 不序列化
Margin Padding 不序列化
Menu MainMenu 不序列化
MinimumSize Size 不序列化
Padding Padding 不序列化
Size Size 不序列化
StartPosition FormStartPosition 不序列化
TopMost Boolean 不序列化
TransparencyKey Color 不序列化
UseWaitCursor Boolean 不序列化
WindowState FormWindowState 不序列化
AccessibleRole AccessibleRole 不序列化
AccessibleDescription String 不序列化
AccessibleName String 不序列化
CausesValidation Boolean 不序列化
DataBindings(RO) ControlBindingsCollection 不序列化
Enabled Boolean 不序列化
Location Point 不序列化
Tag Object 不序列化
AllowDrop Boolean 不序列化
Cursor Cursor 不序列化
BackgroundImage Image 不序列化
BackgroundImageLayout ImageLayout 不序列化
ImeMode ImeMode 不序列化
AutoScrollMargin Size 不序列化
AutoScrollMinSize Size 不序列化
Anchor AnchorStyles 不序列化
Visible Boolean 不序列化
ForeColor Color 不序列化
RightToLeft RightToLeft 不序列化
RightToLeftLayout Boolean 不序列化
TabStop Boolean 不序列化
Text String 不序列化
Dock DockStyle 不序列化
Font Font 不序列化
ContextMenu ContextMenu 不序列化
DockPadding(RO) DockPaddingEdges 不序列化
UseAntiAlias Boolean False 非默认才写
AutoScaleBaseSize Size 不序列化
Document PrintDocument —
MinimizeBox Boolean False 不序列化
PrintPreviewControl(RO) PrintPreviewControl 不序列化
Opacity Double 不序列化
ShowInTaskbar Boolean False 不序列化
SizeGripStyle SizeGripStyle Hide 不序列化
  • 继承 Form(20 个):ActiveMdiChild(RO), AllowTransparency, AutoSizeMode, ClientSize, DesktopBounds, DesktopLocation, DialogResult, IsMdiChild(RO), IsRestrictedWindow(RO), MainMenuStrip, MdiChildren(RO), MdiParent, MergedMenu(RO), Modal(RO), OwnedForms(RO), Owner, RestoreBounds(RO), ShowIcon, TabIndex, TopLevel
  • 继承 ContainerControl(6 个):AutoScaleDimensions, AutoScaleMode, BindingContext, ActiveControl, CurrentAutoScaleDimensions(RO), ParentForm(RO)
  • 继承 ScrollableControl(4 个):AutoScrollPosition, DisplayRectangle(RO), HorizontalScroll(RO), VerticalScroll(RO)
  • 继承 Control(39 个):AccessibilityObject(RO), AccessibleDefaultActionDescription, AutoScrollOffset, LayoutEngine(RO), Bottom(RO), Bounds, CanFocus(RO), CanSelect(RO), Capture, ClientRectangle(RO), CompanyName(RO), ContainsFocus(RO), Controls(RO), Created(RO), DeviceDpi(RO), IsDisposed(RO), Disposing(RO), Focused(RO), Handle(RO), HasChildren(RO), Height, IsHandleCreated(RO), InvokeRequired(RO), IsAccessible, IsMirrored(RO), Left, Name, Parent, ProductName(RO), ProductVersion(RO), RecreatingHandle(RO), Region, Right(RO), Site, Top, TopLevelControl(RO), Width, WindowTarget, PreferredSize(RO)
  • 继承 Component(1 个):Container(RO)

自有事件:AutoSizeChanged(EH);AutoValidateChanged(EH);BackColorChanged(EH);ContextMenuStripChanged(EH);MaximumSizeChanged(EH);MarginChanged(EH);MinimumSizeChanged(EH);PaddingChanged(EH);SizeChanged(EH);CausesValidationChanged(EH);EnabledChanged(EH);LocationChanged(EH);CursorChanged(EH);BackgroundImageChanged(EH);BackgroundImageLayoutChanged(EH);ImeModeChanged(EH);VisibleChanged(EH);ForeColorChanged(EH);RightToLeftChanged(EH);RightToLeftLayoutChanged(EH);TabStopChanged(EH);TextChanged(EH);DockChanged(EH);FontChanged(EH);ContextMenuChanged(EH)

组件运行时总规则

  • 对话框组件(Color/Font/File/Folder/Print/PageSetup/PrintPreview Dialog):设计器只配置开关属性,ShowDialog()/结果属性一律运行时。
  • Timer/FileSystemWatcher/EventLog/SerialPort 的 Enabled/EnableRaisingEvents 是运行时开关。
  • 托盘组件(无 UI)在 Designer.cs 生成于 components 容器:new System.ComponentModel.Container() → this.timer1 = new System.Windows.Forms.Timer(this.components);