DataGridViewPaintParts 列挙体
この列挙体には、メンバ値のビットごとの組み合わせを可能にする FlagsAttribute 属性が含まれています。
名前空間: System.Windows.Formsアセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

<FlagsAttribute> _ Public Enumeration DataGridViewPaintParts

メンバ名 | 説明 | |
---|---|---|
All | セルのすべての部分を描画する必要があります。 | |
Background | セルの背景を描画する必要があります。 | |
Border | セルの境界線を描画する必要があります。 | |
ContentBackground | セルの内容の背景を描画する必要があります。 | |
ContentForeground | セルの内容の前景を描画する必要があります。 | |
ErrorIcon | セルのエラー アイコンを描画する必要があります。 | |
Focus | セルの周囲にフォーカスを示す四角形を描画する必要があります。 | |
None | 何も描画しません。 | |
SelectionBackground | セルが選択されたときに、セルの背景を描画する必要があります。 |

この列挙体は、プロテクト メソッド DataGridViewCell.Paint によって使用されるほか、DataGridView コントロールの CellPainting、RowPrePaint および RowPostPaint の各イベント用のハンドラでも使用されます。

この型の使用方法を次のコード例に示します。次の例は「方法 : Windows フォームの DataGridView コントロールの行の外観をカスタマイズする」で取り上げている例の一部です。
' Paints the custom selection background for selected rows. Sub dataGridView1_RowPrePaint(ByVal sender As Object, _ ByVal e As DataGridViewRowPrePaintEventArgs) _ Handles dataGridView1.RowPrePaint ' Do not automatically paint the focus rectangle. e.PaintParts = e.PaintParts And Not DataGridViewPaintParts.Focus ' Determine whether the cell should be painted with the ' custom selection background. If (e.State And DataGridViewElementStates.Selected) = _ DataGridViewElementStates.Selected Then ' Calculate the bounds of the row. Dim rowBounds As New Rectangle( _ Me.dataGridView1.RowHeadersWidth, e.RowBounds.Top, _ Me.dataGridView1.Columns.GetColumnsWidth( _ DataGridViewElementStates.Visible) - _ Me.dataGridView1.HorizontalScrollingOffset + 1, _ e.RowBounds.Height) ' Paint the custom selection background. Dim backbrush As New _ System.Drawing.Drawing2D.LinearGradientBrush(rowBounds, _ Me.dataGridView1.DefaultCellStyle.SelectionBackColor, _ e.InheritedRowStyle.ForeColor, _ System.Drawing.Drawing2D.LinearGradientMode.Horizontal) Try e.Graphics.FillRectangle(backbrush, rowBounds) Finally backbrush.Dispose() End Try End If End Sub 'dataGridView1_RowPrePaint
// Paints the custom selection background for selected rows. void dataGridView1_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e) { // Do not automatically paint the focus rectangle. e.PaintParts &= ~DataGridViewPaintParts.Focus; // Determine whether the cell should be painted // with the custom selection background. if ((e.State & DataGridViewElementStates.Selected) == DataGridViewElementStates.Selected) { // Calculate the bounds of the row. Rectangle rowBounds = new Rectangle( this.dataGridView1.RowHeadersWidth, e.RowBounds.Top , this.dataGridView1.Columns.GetColumnsWidth( DataGridViewElementStates.Visible) - this.dataGridView1.HorizontalScrollingOffset + 1, e.RowBounds.Height); // Paint the custom selection background. using (Brush backbrush = new System.Drawing.Drawing2D.LinearGradientBrush(rowBounds , this.dataGridView1.DefaultCellStyle.SelectionBackColor , e.InheritedRowStyle.ForeColor, System.Drawing.Drawing2D.LinearGradientMode.Horizontal)) { e.Graphics.FillRectangle(backbrush, rowBounds); } } }

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からDataGridViewPaintParts 列挙体を検索する場合は、下記のリンクをクリックしてください。

- DataGridViewPaintParts 列挙体のページへのリンク