DataGridViewImageCell クラス
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
DataGridView コントロール内にグラフィックを表示します。
public ref class DataGridViewImageCell : System::Windows::Forms::DataGridViewCell
public class DataGridViewImageCell : System.Windows.Forms.DataGridViewCell
type DataGridViewImageCell = class
inherit DataGridViewCell
Public Class DataGridViewImageCell
Inherits DataGridViewCell
- 継承
次のコード例では、 を使用してイメージ セル内のイメージを変更する方法を DataGridViewCell示します。 このコード例は、「How to: Work with Image Columns in the Windows フォーム DataGridView Control」トピックで提供される大きな例の一部です。
void dataGridView1_CellClick( Object^ sender, DataGridViewCellEventArgs^ e )
{
if ( turn->Equals( gameOverString ) )
{
return;
}
DataGridViewImageCell^ cell = dynamic_cast<DataGridViewImageCell^>(dataGridView1->Rows[ e->RowIndex ]->Cells[ e->ColumnIndex ]);
if ( cell->Value == blank )
{
if ( IsOsTurn() )
{
cell->Value = o;
}
else
{
cell->Value = x;
}
ToggleTurn();
}
if ( IsAWin( cell ) )
{
turn->Text = gameOverString;
}
}
private void dataGridView1_CellClick(object sender,
DataGridViewCellEventArgs e)
{
if (turn.Text.Equals(gameOverString)) { return; }
DataGridViewImageCell cell = (DataGridViewImageCell)
dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex];
if (cell.Value == blank)
{
if (IsOsTurn())
{
cell.Value = o;
}
else
{
cell.Value = x;
}
ToggleTurn();
}
if (IsAWin())
{
turn.Text = gameOverString;
}
}
Private Sub dataGridView1_CellClick(ByVal sender As Object, _
ByVal e As DataGridViewCellEventArgs) _
Handles dataGridView1.CellClick
If turn.Text.Equals(gameOverString) Then Return
Dim cell As DataGridViewImageCell = _
CType(dataGridView1.Rows(e.RowIndex). _
Cells(e.ColumnIndex), DataGridViewImageCell)
If (cell.Value Is blank) Then
If IsOsTurn() Then
cell.Value = o
Else
cell.Value = x
End If
ToggleTurn()
ToolTip(e)
End If
If IsAWin() Then
turn.Text = gameOverString
End If
End Sub
クラスはDataGridViewImageCell、 プロパティのDataGridViewCell値ValueIsIconに応じて、 または をIcon表示Imageするために使用される 特殊化された 型です。 通常、 の ReadOnlyDataGridViewImageCell プロパティは、 に true
設定され、ユーザーがセルの内容を編集できないことを示します。
DataGridViewImageColumnは、この型のセルを保持するために特殊化された列型です。 既定では、 DataGridViewImageColumn.CellTemplate は新 DataGridViewImageCellしい に初期化されます。 既存 DataGridViewImageCellの の後の列内のセルをパターン設定するには、パターンとして使用するセルに列の CellTemplate プロパティを設定します。
列のセル関連プロパティは、テンプレート セルの同様の名前のプロパティのラッパーです。 テンプレート セルのプロパティ値を変更すると、変更後に追加されたテンプレートに基づくセルにのみ影響します。 ただし、列のセル関連のプロパティ値を変更すると、テンプレート セルと列内の他のすべてのセルが更新され、必要に応じて列の表示が更新されます。
から DataGridViewImageCell 派生し、派生クラスに新しいプロパティを追加するときは、 メソッドをオーバーライド Clone() して、複製操作中に新しいプロパティをコピーしてください。 基底クラスの Clone() プロパティが新しいセルにコピーされるように、基底クラスの メソッドも呼び出す必要があります。
Data |
DataGridViewImageCell クラスの新しいインスタンスを初期化し、セル値が Icon オブジェクト以外の場合に使用するよう構成します。 |
Data |
DataGridViewImageCell クラスの新しいインスタンスを初期化し、オプションでセル値が Icon である場合に使用するよう構成します。 |
Accessibility |
DataGridViewCell.DataGridViewCellAccessibleObject に割り当てられた DataGridViewCell を取得します。 (継承元 DataGridViewCell) |
Column |
このセルの列インデックスを取得します。 (継承元 DataGridViewCell) |
Content |
セルの内容領域を囲んだ外接する四角形を取得します。 (継承元 DataGridViewCell) |
Context |
セルに関連付けられたショートカット メニューを取得または設定します。 (継承元 DataGridViewCell) |
Data |
この要素に関連付けられている DataGridView コントロールを取得します。 (継承元 DataGridViewElement) |
Default |
新しい行を作成するときに使用する既定値を取得します。 |
Description |
イメージに関連付けられたテキストを取得または設定します。 |
Displayed |
セルが現在画面上に表示されているかどうかを示す値を取得します。 (継承元 DataGridViewCell) |
Edited |
セルが編集モードであるかどうか、および値がコミットされているかどうかに関係なく、セルの現在の書式指定済みの値を取得します。 (継承元 DataGridViewCell) |
Edit |
セルのホストされる編集コントロールの型を取得します。 |
Error |
セルのエラー アイコンの境界を取得します。 (継承元 DataGridViewCell) |
Error |
セルに関連付けられたエラー条件を記述するテキストを取得または設定します。 (継承元 DataGridViewCell) |
Formatted |
表示用に書式指定済みのセル値を取得します。 (継承元 DataGridViewCell) |
Formatted |
セルに関連付けられている、書式設定された値の型を取得します。 |
Frozen |
セルが固定された状態かどうかを示す値を取得します。 (継承元 DataGridViewCell) |
Has |
Style プロパティが設定されているかどうかを示す値を取得します。 (継承元 DataGridViewCell) |
Image |
セルのグラフィックスのレイアウトを取得または設定します。 |
Inherited |
行と列の状態から継承されたセルの現在の状態を取得します。 (継承元 DataGridViewCell) |
Inherited |
セルに現在適用されているスタイルを取得します。 (継承元 DataGridViewCell) |
Is |
このセルが現在編集されているかどうかを示す値を取得します。 (継承元 DataGridViewCell) |
Owning |
セルを格納している列を取得します。 (継承元 DataGridViewCell) |
Owning |
セルを格納している行を取得します。 (継承元 DataGridViewCell) |
Preferred |
セルが収まる四角形領域のサイズをピクセル単位で取得します。 (継承元 DataGridViewCell) |
Read |
セルのデータを編集できるかどうかを示す値を取得または設定します。 (継承元 DataGridViewCell) |
Resizable |
セルのサイズを変更できるかどうかを示す値を取得します。 (継承元 DataGridViewCell) |
Row |
セルの親行のインデックスを取得します。 (継承元 DataGridViewCell) |
Selected |
セルが選択されているかどうかを示す値を取得または設定します。 (継承元 DataGridViewCell) |
Size |
セルのサイズを取得します。 (継承元 DataGridViewCell) |
State |
要素のユーザー インターフェイス (UI) の状態を取得します。 (継承元 DataGridViewElement) |
Style |
セルのスタイルを取得または設定します。 (継承元 DataGridViewCell) |
Tag |
セルに関する補足的なデータを格納するオブジェクトを取得または設定します。 (継承元 DataGridViewCell) |
Tool |
このセルに関連付けられているツールヒント テキストを取得または設定します。 (継承元 DataGridViewCell) |
Value |
このセルに関連付けられている値を取得または設定します。 (継承元 DataGridViewCell) |
Value |
このセルに Icon 値を表示するかどうかを示す値を取得または設定します。 |
Value |
セル内の値のデータ型を取得または設定します。 |
Visible |
非表示にされた行または列にセルが含まれるかどうかを示す値を取得します。 (継承元 DataGridViewCell) |
製品 | バージョン |
---|---|
.NET Framework | 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, 10 |
.NET に関するフィードバック
.NET はオープンソース プロジェクトです。 フィードバックを提供するにはリンクを選択します。