DataGridViewRowPostPaintEventArgs.Graphics プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

現在の DataGridViewRow の描画に使用する Graphics。


Graphics プロパティを使用して、カスタムの背景を描画する方法を次のコード例に示します。このコードで実際に使用するのは DataGridViewRowPrePaintEventArgs.Graphics プロパティですが、このプロパティは DataGridViewRowPostPaintEventArgs の Graphics プロパティとほぼ同じです。変数 e の型が DataGridViewRowPrePaintEventArgs です。次のコード例は、「方法 : Windows フォームの DataGridView コントロールの行の外観をカスタマイズする」で示されている例の一部です。
' 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
// 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に収録されているすべての辞書からDataGridViewRowPostPaintEventArgs.Graphics プロパティを検索する場合は、下記のリンクをクリックしてください。

- DataGridViewRowPostPaintEventArgs.Graphics プロパティのページへのリンク