DataGridViewCell クラス
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Public MustInherit Class DataGridViewCell Inherits DataGridViewElement Implements ICloneable, IDisposable
public abstract class DataGridViewCell : DataGridViewElement, ICloneable, IDisposable
public abstract class DataGridViewCell extends DataGridViewElement implements ICloneable, IDisposable
public abstract class DataGridViewCell extends DataGridViewElement implements ICloneable, IDisposable

DataGridViewCell クラスは DataGridView コントロールの個別のセルを表します。セルを取得するには、DataGridViewRow の Cells コレクションを使用します。
DataGridViewCell の行と列は、DataGridView 内のセルの位置を識別します。一般的なセルには、それが格納されている行と列に固有のデータが含まれています。セルは、プロパティの設定や関連付けられたイベントの処理により、数多くの方法でカスタマイズできます。
継承時の注意 DataGridViewCell からクラスを派生させて新しいプロパティを追加する場合は、Clone メソッドをオーバーライドして、クローン操作時に新しいプロパティをコピーする必要があります。また、基本クラスの Clone メソッドも呼び出して、基本クラスのプロパティが新しいセルにコピーされるようにする必要があります。
この型の使用方法を次のコード例に示します。この例の詳細については、「方法 : Windows フォーム DataGridView コントロールの各セルにツールヒントを追加する」を参照してください。
' Sets the ToolTip text for cells in the Rating column. Sub dataGridView1_CellFormatting(ByVal sender As Object, _ ByVal e As DataGridViewCellFormattingEventArgs) _ Handles dataGridView1.CellFormatting If e.ColumnIndex = Me.dataGridView1.Columns("Rating").Index _ AndAlso Not (e.Value Is Nothing) Then With Me.dataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex) If e.Value.Equals("*") Then .ToolTipText = "very bad" ElseIf e.Value.Equals("**") Then .ToolTipText = "bad" ElseIf e.Value.Equals("***") Then .ToolTipText = "good" ElseIf e.Value.Equals("****") Then .ToolTipText = "very good" End If End With End If End Sub 'dataGridView1_CellFormatting
// Sets the ToolTip text for cells in the Rating column. void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if ( (e.ColumnIndex == this.dataGridView1.Columns["Rating"].Index) && e.Value != null ) { DataGridViewCell cell = this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex]; if (e.Value.Equals("*")) { cell.ToolTipText = "very bad"; } else if (e.Value.Equals("**")) { cell.ToolTipText = "bad"; } else if (e.Value.Equals("***")) { cell.ToolTipText = "good"; } else if (e.Value.Equals("****")) { cell.ToolTipText = "very good"; } } }
// Sets the ToolTip text for cells in the Rating column. void dataGridView1_CellFormatting(Object^ /*sender*/, DataGridViewCellFormattingEventArgs^ e) { if ( (e->ColumnIndex == this->dataGridView1->Columns["Rating"]->Index) && e->Value != nullptr ) { DataGridViewCell^ cell = this->dataGridView1->Rows[e->RowIndex]->Cells[e->ColumnIndex]; if (e->Value->Equals("*")) { cell->ToolTipText = "very bad"; } else if (e->Value->Equals("**")) { cell->ToolTipText = "bad"; } else if (e->Value->Equals("***")) { cell->ToolTipText = "good"; } else if (e->Value->Equals("****")) { cell->ToolTipText = "very good"; } } }



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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


DataGridViewCell メンバ
System.Windows.Forms 名前空間
DataGridView クラス
System.ICloneable
System.IDisposable
- DataGridViewCell クラスのページへのリンク