DataGridViewImageColumnとは? わかりやすく解説

DataGridViewImageColumn イベント


パブリック イベントパブリック イベント

  名前 説明
パブリック イベント Disposed  DataGridViewColumn が破棄されたときに発生します。 ( DataGridViewColumn から継承されます。)
参照参照

関連項目

DataGridViewImageColumn クラス
System.Windows.Forms 名前空間
DataGridView クラス
DataGridViewColumn クラス
DataGridViewRow
DataGridViewImageCell クラス
DataGridViewImageCell.ValueIsIcon
Image
Icon
DataGridViewColumn.SortMode プロパティ

DataGridViewImageColumn クラス

メモ : このクラスは、.NET Framework version 2.0 で新しく追加されたものです。

DataGridViewImageCell オブジェクトのコレクションをホストします。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Class DataGridViewImageColumn
    Inherits DataGridViewColumn
Dim instance As DataGridViewImageColumn
public class DataGridViewImageColumn : DataGridViewColumn
public ref class DataGridViewImageColumn :
 public DataGridViewColumn
public class DataGridViewImageColumn extends
 DataGridViewColumn
public class DataGridViewImageColumn extends
 DataGridViewColumn
解説解説

DataGridViewImageColumn クラスは、DataGridViewColumn クラスの特殊な型で、イメージを表示するセルを論理的にホストするために使用されます。DataGridViewImageColumn には、それと交差するすべての DataGridViewRow 内に、関連付けられた DataGridViewImageCell があります。各セルには、DataGridViewImageCell.ValueIsIcon プロパティの値に応じて、Image または Icon を格納できます。イメージに透明度を持たせる場合は、アイコンを表示すると便利です。

既定では、空のセルには既定のエラー グラフィックが表示されます。セルの値が null 参照 (Visual Basic では Nothing) または DBNull.Value である場合にこのグラフィックが表示されないようにするには、コントロールに行を追加する前に、DefaultCellStyle プロパティによって返されるセル スタイル オブジェクトの DataGridViewCellStyle.NullValue プロパティを null 参照 (Visual Basic では Nothing) に設定します。ただし、この設定は新しいレコードの行には適用されません。コントロールの AllowUserToAddRows プロパティの値が true である場合に、新しいレコードの行にエラー グラフィックが表示されないようにするには、コントロールの RowsAdded イベントのハンドラ内でセルの値を明示的に null 参照 (Visual Basic では Nothing) に設定するか、DefaultNewRowValue プロパティをオーバーライドして null 参照 (Visual Basic では Nothing) を返すようにした DataGridViewImageCell の派生型のインスタンスを、列の CellTemplate プロパティに設定する必要があります。

この列型の既定の並べ替えモードは、NotSortable です。

継承時の注意 DataGridViewImageColumn からクラスを派生させて新しいプロパティを追加する場合は、Clone メソッドをオーバーライドして、クローン操作時に新しいプロパティをコピーする必要があります。また、基本クラスの Clone メソッドも呼び出して、基本クラスのプロパティが新しいセルにコピーされるようにする必要があります。

使用例使用例

次のコード例は、イメージを使用して三目並べゲームを作成する方法を示しています。

Imports System.IO
Imports System.Windows.Forms
Imports System.Drawing
Imports System

Public Class TicTacToe
    Inherits System.Windows.Forms.Form

    Friend WithEvents dataGridView1 As
 DataGridView
    Friend WithEvents Button1 As
 Button = New Button()
    Friend WithEvents turn As
 Label = New Label()
    Friend WithEvents Button2 As
 Button = New Button()
    Friend WithEvents Button3 As
 Button = New Button()
    Friend WithEvents Button4 As
 Button = New Button()
    Friend WithEvents Button5 As
 Button = New Button()
    Friend WithEvents Panel1 As
 FlowLayoutPanel = New FlowLayoutPanel()

#Region "bitmaps"
    Private oImage As Byte()
 = { _
        &H42, &H4D, &HC6, &H0, &H0, &H0, &H0, &H0,
 _
        &H0, &H0, &H76, &H0, &H0, &H0, &H28, &H0,
 _
        &H0, &H0, &HB, &H0, &H0, &H0, &HA, &H0, _
        &H0, &H0, &H1, &H0, &H4, &H0, &H0, &H0, _
        &H0, &H0, &H50, &H0, &H0, &H0, &H0, &H0,
 _
        &H0, &H0, &H0, &H0, &H0, &H0, &H10, &H0,
 _
        &H0, &H0, &H10, &H0, &H0, &H0, &H0, &H0,
 _
        &H0, &H0, &H0, &H0, &H80, &H0, &H0, &H80,
 _
        &H0, &H0, &H0, &H80, &H80, &H0, &H80, &H0,
 _
        &H0, &H0, &H80, &H0, &H80, &H0, &H80, &H80,
 _
        &H0, &H0, &HC0, &HC0, &HC0, &H0, &H80, &H80,
 _
        &H80, &H0, &H0, &H0, &HFF, &H0, &H0, &HFF,
 _
        &H0, &H0, &H0, &HFF, &HFF, &H0, &HFF, &H0,
 _
        &H0, &H0, &HFF, &H0, &HFF, &H0, &HFF, &HFF,
 _
        &H0, &H0, &HFF, &HFF, &HFF, &H0, &HFF, &HFF,
 _
        &H0, &HF, &HFF, &HF0, &H0, &H0, &HFF, &H0,
 _
        &HFF, &HF0, &HF, &HF0, &H0, &H0, &HF0, &HFF,
 _
        &HFF, &HFF, &HF0, &HF0, &H0, &H0, &HF0, &HFF,
 _
        &HFF, &HFF, &HF0, &HF0, &H0, &H0, &HF, &HFF,
 _
        &HFF, &HFF, &HFF, &H0, &H0, &H0, &HF, &HFF,
 _
        &HFF, &HFF, &HFF, &H0, &H0, &H0, &HF0, &HFF,
 _
        &HFF, &HFF, &HF0, &HF0, &H0, &H0, &HF0, &HFF,
 _
        &HFF, &HFF, &HF0, &HF0, &H0, &H0, &HFF, &H0,
 _
        &HFF, &HF0, &HF, &HF0, &H0, &H0, &HFF, &HFF,
 _
        &H0, &HF, &HFF, &HF0, &H0, &H0}

    Private xImage As Byte()
 = { _
        &H42, &H4D, &HC6, &H0, &H0, &H0, &H0, &H0,
 _
        &H0, &H0, &H76, &H0, &H0, &H0, &H28, &H0,
 _
        &H0, &H0, &HB, &H0, &H0, &H0, &HA, &H0, _
        &H0, &H0, &H1, &H0, &H4, &H0, &H0, &H0, _
        &H0, &H0, &H50, &H0, &H0, &H0, &H0, &H0,
 _
        &H0, &H0, &H0, &H0, &H0, &H0, &H10, &H0,
 _
        &H0, &H0, &H10, &H0, &H0, &H0, &H0, &H0,
 _
        &H0, &H0, &H0, &H0, &H80, &H0, &H0, &H80,
 _
        &H0, &H0, &H0, &H80, &H80, &H0, &H80, &H0,
 _
        &H0, &H0, &H80, &H0, &H80, &H0, &H80, &H80,
 _
        &H0, &H0, &HC0, &HC0, &HC0, &H0, &H80, &H80,
 _
        &H80, &H0, &H0, &H0, &HFF, &H0, &H0, &HFF,
 _
        &H0, &H0, &H0, &HFF, &HFF, &H0, &HFF, &H0,
 _
        &H0, &H0, &HFF, &H0, &HFF, &H0, &HFF, &HFF,
 _
        &H0, &H0, &HFF, &HFF, &HFF, &H0, &HF0, &HFF,
 _
        &HFF, &HFF, &HF0, &HF0, &H0, &H0, &HFF, &HF,
 _
        &HFF, &HFF, &HF, &HF0, &H0, &H0, &HFF, &HF0,
 _
        &HFF, &HF0, &HFF, &HF0, &H0, &H0, &HFF, &HFF,
 _
        &HF, &HF, &HFF, &HF0, &H0, &H0, &HFF, &HFF,
 _
        &HF, &HF, &HFF, &HF0, &H0, &H0, &HFF, &HFF,
 _
        &HF, &HF, &HFF, &HF0, &H0, &H0, &HFF, &HF0,
 _
        &HFF, &HF0, &HFF, &HF0, &H0, &H0, &HFF, &HF,
 _
        &HFF, &HFF, &HF, &HF0, &H0, &H0, &HF0, &HFF,
 _
        &HFF, &HFF, &HF0, &HF0, &H0, &H0, &HFF, &HFF,
 _
        &HFF, &HFF, &HFF, &HF0, &H0, &H0}

    Private blankImage As Byte()
 = { _
        &H42, &H4D, &HC6, &H0, &H0, &H0, &H0, &H0,
 _
        &H0, &H0, &H76, &H0, &H0, &H0, &H28, &H0,
 _
        &H0, &H0, &HB, &H0, &H0, &H0, &HA, &H0, _
        &H0, &H0, &H1, &H0, &H4, &H0, &H0, &H0, _
        &H0, &H0, &H50, &H0, &H0, &H0, &H0, &H0,
 _
        &H0, &H0, &H0, &H0, &H0, &H0, &H10, &H0,
 _
        &H0, &H0, &H10, &H0, &H0, &H0, &H0, &H0,
 _
        &H0, &H0, &H0, &H0, &H80, &H0, &H0, &H80,
 _
        &H0, &H0, &H0, &H80, &H80, &H0, &H80, &H0,
 _
        &H0, &H0, &H80, &H0, &H80, &H0, &H80, &H80,
 _
        &H0, &H0, &HC0, &HC0, &HC0, &H0, &H80, &H80,
 _
        &H80, &H0, &H0, &H0, &HFF, &H0, &H0, &HFF,
 _
        &H0, &H0, &H0, &HFF, &HFF, &H0, &HFF, &H0,
 _
        &H0, &H0, &HFF, &H0, &HFF, &H0, &HFF, &HFF,
 _
        &H0, &H0, &HFF, &HFF, &HFF, &H0, &HFF, &HFF,
 _
        &HFF, &HFF, &HFF, &HF0, &H0, &H0, &HFF, &HFF,
 _
        &HFF, &HFF, &HFF, &HF0, &H0, &H0, &HFF, &HFF,
 _
        &HFF, &HFF, &HFF, &HF0, &H0, &H0, &HFF, &HFF,
 _
        &HFF, &HFF, &HFF, &HF0, &H0, &H0, &HFF, &HFF,
 _
        &HFF, &HFF, &HFF, &HF0, &H0, &H0, &HFF, &HFF,
 _
        &HFF, &HFF, &HFF, &HF0, &H0, &H0, &HFF, &HFF,
 _
        &HFF, &HFF, &HFF, &HF0, &H0, &H0, &HFF, &HFF,
 _
        &HFF, &HFF, &HFF, &HF0, &H0, &H0, &HFF, &HFF,
 _
        &HFF, &HFF, &HFF, &HF0, &H0, &H0, &HFF, &HFF,
 _
        &HFF, &HFF, &HFF, &HF0, &H0, &H0}
#End Region

    Private blank As Bitmap = New
 Bitmap( _
        New MemoryStream(blankImage))
    Private x As Bitmap = New
 Bitmap(New MemoryStream(xImage))
    Private o As Bitmap = New
 Bitmap(New MemoryStream(oImage))
    Private xString As String
 = "X's turn"
    Private oString As String
 = "O's turn"
    Private gameOverString As String
 = "Game Over"
    Private bitmapPadding As Integer
 = 6

    Private Sub InitializeDataGridView(ByVal
 sender As Object, _
        ByVal e As EventArgs) Handles
 Me.Load
        SuspendLayout()
        Panel1.SuspendLayout()

        ConfigureForm()
        SizeGrid()
        CreateColumns()
        CreateRows()

        ResumeLayout(False)
        Panel1.ResumeLayout(False)
    End Sub

    Private Sub ConfigureForm()
        AutoSize = True
        turn.Size = New System.Drawing.Size(75, 34)
        turn.TextAlign = ContentAlignment.MiddleLeft
        turn.Text = xString

        Panel1.FlowDirection = FlowDirection.TopDown
        Panel1.Location = New System.Drawing.Point(0, 8)
        Panel1.Size = New System.Drawing.Size(120, 196)

        ClientSize = New System.Drawing.Size(355, 200)
        Controls.Add(Me.Panel1)
        Text = "TicTacToe"

        dataGridView1 = New System.Windows.Forms.DataGridView
        dataGridView1.Location = New Point(120, 0)
        dataGridView1.AllowUserToAddRows = False
        Controls.Add(dataGridView1)
        SetupButtons()
    End Sub

    Private Sub SetupButtons()
        SetupButton(Button1, "Restart")
        Panel1.Controls.Add(Me.turn)
        SetupButton(Button2, "Increase Cell Size")
        SetupButton(Button3, "Stretch Images")
        SetupButton(Button4, "Zoom Images")
        SetupButton(Button5, "Normal Images")
    End Sub

    Private Sub SetupButton(ByVal
 button As Button, _
        ByVal buttonLabel As String)

        Panel1.Controls.Add(button)
        button.Text = buttonLabel
        button.AutoSize = True

    End Sub

    Private Sub CreateColumns()

        Dim imageColumn As DataGridViewImageColumn
        Dim columnCount As Integer
 = 0
        Do
            Dim unMarked As Bitmap = blank
            imageColumn = New DataGridViewImageColumn()

            ' Add twice the padding for the left and 
            ' right sides of the cell.
            imageColumn.Width = x.Width + 2 * bitmapPadding + 1

            imageColumn.Image = unMarked
            imageColumn.ImageLayout = DataGridViewImageCellLayout.NotSet
            imageColumn.Description = "default image layout"
            dataGridView1.Columns.Add(imageColumn)
            columnCount = columnCount + 1
        Loop While columnCount < 3
    End Sub

    Private Sub CreateRows()
        dataGridView1.Rows.Add()
        dataGridView1.Rows.Add()
        dataGridView1.Rows.Add()
    End Sub

    Private Sub SizeGrid()
        dataGridView1.ColumnHeadersVisible = False
        dataGridView1.RowHeadersVisible = False
        dataGridView1.AllowUserToResizeColumns = False
        dataGridView1.AllowUserToResizeRows = False
        dataGridView1.BorderStyle = BorderStyle.None

        ' Add twice the padding for the top and bottom of the cell.
 
        dataGridView1.RowTemplate.Height = x.Height + _
            2 * bitmapPadding + 1

        dataGridView1.AutoSize = True
    End Sub

    Private Sub reset(ByVal
 sender As Object, _
        ByVal e As EventArgs) _
        Handles Button1.Click

        dataGridView1.Dispose()
        InitializeDataGridView(Nothing, Nothing)
    End Sub

    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

    Private Sub dataGridView1_CellMouseEnter(ByVal
 sender As Object, _
        ByVal e As DataGridViewCellEventArgs)
 _
        Handles dataGridView1.CellMouseEnter

        Dim markingUnderMouse As Bitmap = _
            CType(dataGridView1.Rows(e.RowIndex). _
                Cells(e.ColumnIndex).Value, Bitmap)

        If markingUnderMouse Is blank Then
            dataGridView1.Cursor = Cursors.Default
        ElseIf markingUnderMouse Is o OrElse
 markingUnderMouse Is x Then
            dataGridView1.Cursor = Cursors.No
            ToolTip(e)
        End If
    End Sub

    Private Sub ToolTip( _
        ByVal e As DataGridViewCellEventArgs)

        Dim cell As DataGridViewImageCell =
 _
            CType(dataGridView1.Rows(e.RowIndex). _
            Cells(e.ColumnIndex), DataGridViewImageCell)
        Dim imageColumn As DataGridViewImageColumn
 = _
            CType(dataGridView1.Columns(cell.ColumnIndex), _
            DataGridViewImageColumn)

        cell.ToolTipText = imageColumn.Description
    End Sub

    Private Sub dataGridView1_CellMouseLeave(ByVal
 sender As Object, _
        ByVal e As DataGridViewCellEventArgs)
 _
        Handles dataGridView1.CellMouseLeave

        dataGridView1.Cursor = Cursors.Default
    End Sub

    Private Sub Stretch(ByVal
 sender As Object, _
        ByVal e As EventArgs) Handles
 Button3.Click

        For Each column As
 DataGridViewImageColumn _
            In dataGridView1.Columns
            column.ImageLayout = DataGridViewImageCellLayout.Stretch
            column.Description = "Stretched image layout"
        Next
    End Sub

    Private Sub ZoomToImage(ByVal
 sender As Object, _
        ByVal e As EventArgs) Handles
 Button4.Click

        For Each column As
 DataGridViewImageColumn _
            In dataGridView1.Columns
            column.ImageLayout = DataGridViewImageCellLayout.Zoom
            column.Description = "Zoomed image layout"
        Next
    End Sub

    Private Sub NormalImage(ByVal
 sender As Object, _
        ByVal e As EventArgs) Handles
 Button5.Click

        For Each column As
 DataGridViewImageColumn _
            In dataGridView1.Columns
            column.ImageLayout = DataGridViewImageCellLayout.Normal
            column.Description = "Normal image layout"
        Next
    End Sub

    Private Sub MakeCellsLarger(ByVal
 sender As Object, _
        ByVal e As EventArgs) Handles
 Button2.Click

        For Each column As
 DataGridViewImageColumn _
            In dataGridView1.Columns
            column.Width = column.Width * 2
        Next
        For Each row As
 DataGridViewRow In dataGridView1.Rows
            If row.IsNewRow Then Continue For
            row.Height = CInt(row.Height * 1.5)
        Next
    End Sub

    Private Function IsAWin() As
 Boolean
        If ARowIsSame() OrElse AColumnIsSame()
 OrElse ADiagonalIsSame() Then
            Return True
        Else 
            Return False
        End If
    End Function

    Private Function ARowIsSame() As
 Boolean
        Dim marking As Bitmap = Nothing
        If marking Is blank Then
 Return False
        For Each row As
 DataGridViewRow In dataGridView1.Rows
            If row.IsNewRow Then Continue For
            marking = CType(row.Cells(0).Value, Bitmap)
            If Not marking Is
 blank Then
                If marking Is row.Cells(1).Value
 AndAlso _
                    marking Is row.Cells(2).Value Then
 Return True
            End If
        Next
        Return False
    End Function

    Private Function AColumnIsSame() As
 Boolean

        Dim columnIndex As Integer
 = 0
        Dim marking As Bitmap
        Do
            marking = CType(dataGridView1.Rows(0).Cells(columnIndex).Value, _
                Bitmap)
            If Not marking Is
 blank Then
                If marking Is _
                    dataGridView1.Rows(1).Cells(columnIndex).Value _
                    AndAlso marking Is _
                    dataGridView1.Rows(2).Cells(columnIndex).Value _
                    Then Return True
            End If
            columnIndex = columnIndex + 1
        Loop While columnIndex < _
            dataGridView1.Columns.GetColumnCount( _
            DataGridViewElementStates.Visible)
        Return False
    End Function

    Private Function ADiagonalIsSame() As
 Boolean

        If LeftToRightDiagonalIsSame() Then
 Return True
        If RightToLeftDiagonalIsSame() Then
 Return True
        Return False
    End Function

    Private Function LeftToRightDiagonalIsSame()
 As Boolean
        Return IsDiagonalSame(0, 2)
    End Function

    Private Function RightToLeftDiagonalIsSame()
 As Boolean
        Return IsDiagonalSame(2, 0)
    End Function

    Private Function IsDiagonalSame(ByVal
 startingColumn As Integer, _
        ByVal lastColumn As Integer)
 As Boolean

        Dim marking As Bitmap = CType( _
            dataGridView1.Rows(0).Cells(startingColumn).Value, Bitmap)
        If marking Is blank Then
 Return False
        If marking Is dataGridView1.Rows(1).Cells(1).Value
 AndAlso _
            marking Is dataGridView1.Rows(2).Cells(lastColumn).Value
 _
            Then Return True
    End Function

    Private Sub ToggleTurn()
        If turn.Text.Equals(xString) Then turn.Text
 = oString _
        Else turn.Text = xString
    End Sub

    Private Function IsOsTurn() As
 Boolean
        If turn.Text.Equals(oString) Then Return
 True _
        Else  : Return False
    End Function

    <STAThread> Public Shared Sub
 Main()
        Application.Run(New TicTacToe())
    End Sub

End Class
using System.IO;
using System.Windows.Forms;
using System.Drawing;
using System;

public class TicTacToe : System.Windows.Forms.Form
{
    public TicTacToe()
    {
        blank = new Bitmap(new MemoryStream(blankImage));
        x = new Bitmap(new MemoryStream(xImage));
        o = new Bitmap(new MemoryStream(oImage));

        this.AutoSize = true;
        SetupButtons();
        InitializeDataGridView(null, null);
    }

    private DataGridView dataGridView1;
    private Button Button1 = new Button();
    private Label turn = new Label();
    private Button Button2 = new Button();
    private Button Button3 = new Button();
    private Button Button4 = new Button();
    private Button Button5 = new Button();
    private FlowLayoutPanel Panel1 = new FlowLayoutPanel();

    #region "bitmaps"
    private byte[] oImage = new byte[] {
        0x42, 0x4D, 0xC6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x76, 
        0x0, 0x0, 0x0, 0x28, 0x0, 0x0, 0x0, 0xB, 0x0, 0x0, 0x0, 0xA,
        0x0, 0x0, 0x0, 0x1, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x50,
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10,
        0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
        0x0, 0x80, 0x0, 0x0, 0x80, 0x0, 0x0, 0x0, 0x80, 0x80, 0x0, 
        0x80, 0x0, 0x0, 0x0, 0x80, 0x0, 0x80, 0x0, 0x80, 0x80, 0x0, 
        0x0, 0xC0, 0xC0, 0xC0, 0x0, 0x80, 0x80, 0x80, 0x0, 0x0, 0x0,
        0xFF, 0x0, 0x0, 0xFF, 0x0, 0x0, 0x0, 0xFF, 0xFF, 0x0, 0xFF, 
        0x0, 0x0, 0x0, 0xFF, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0x0, 0x0, 
        0xFF, 0xFF, 0xFF, 0x0, 0xFF, 0xFF, 0x0, 0xF, 0xFF, 0xF0, 
        0x0, 0x0, 0xFF, 0x0, 0xFF, 0xF0, 0xF, 0xF0, 0x0, 0x0, 0xF0, 
        0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0x0, 0x0, 0xF0, 0xFF, 0xFF, 
        0xFF, 0xF0, 0xF0, 0x0, 0x0, 0xF, 0xFF, 0xFF, 0xFF, 0xFF, 
        0x0, 0x0, 0x0, 0xF, 0xFF, 0xFF, 0xFF, 0xFF, 0x0, 0x0, 0x0, 
        0xF0, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0x0, 0x0, 0xF0, 0xFF, 
        0xFF, 0xFF, 0xF0, 0xF0, 0x0, 0x0, 0xFF, 0x0, 0xFF, 0xF0, 
        0xF, 0xF0, 0x0, 0x0, 0xFF, 0xFF, 0x0, 0xF, 0xFF, 0xF0, 0x0, 
        0x0};

    private byte[] xImage = new byte[]{
        0x42, 0x4D, 0xC6, 0x0, 0x0, 0x0, 0x0, 
        0x0, 0x0, 0x0, 0x76, 0x0, 0x0, 0x0, 0x28, 0x0, 0x0, 0x0, 
        0xB, 0x0, 0x0, 0x0, 0xA, 0x0, 0x0, 0x0, 0x1, 0x0, 0x4, 0x0, 
        0x0, 0x0, 0x0, 0x0, 0x50, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
        0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x80, 0x0, 0x0, 0x80, 
        0x0, 0x0, 0x0, 0x80, 0x80, 0x0, 0x80, 0x0, 0x0, 0x0, 0x80, 
        0x0, 0x80, 0x0, 0x80, 0x80, 0x0, 0x0, 0xC0, 0xC0, 0xC0, 0x0,
        0x80, 0x80, 0x80, 0x0, 0x0, 0x0, 0xFF, 0x0, 0x0, 0xFF, 0x0, 
        0x0, 0x0, 0xFF, 0xFF, 0x0, 0xFF, 0x0, 0x0, 0x0, 0xFF, 0x0, 
        0xFF, 0x0, 0xFF, 0xFF, 0x0, 0x0, 0xFF, 0xFF, 0xFF, 0x0, 
        0xF0, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0x0, 0x0, 0xFF, 0xF, 
        0xFF, 0xFF, 0xF, 0xF0, 0x0, 0x0, 0xFF, 0xF0, 0xFF, 0xF0, 
        0xFF, 0xF0, 0x0, 0x0, 0xFF, 0xFF, 0xF, 0xF, 0xFF, 0xF0, 0x0,
        0x0, 0xFF, 0xFF, 0xF, 0xF, 0xFF, 0xF0, 0x0, 0x0, 0xFF, 0xFF,
        0xF, 0xF, 0xFF, 0xF0, 0x0, 0x0, 0xFF, 0xF0, 0xFF, 0xF0, 
        0xFF, 0xF0, 0x0, 0x0, 0xFF, 0xF, 0xFF, 0xFF, 0xF, 0xF0, 0x0,
        0x0, 0xF0, 0xFF, 0xFF, 0xFF, 0xF0, 0xF0, 0x0, 0x0, 0xFF, 
        0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x0, 0x0};

    private byte[] blankImage = new byte[]
 {
        0x42, 0x4D, 0xC6, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x76, 
        0x0, 0x0, 0x0, 0x28, 0x0, 0x0, 0x0, 0xB, 0x0, 0x0, 0x0, 0xA,
        0x0, 0x0, 0x0, 0x1, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x50,
        0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10,
        0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
        0x0, 0x80, 0x0, 0x0, 0x80, 0x0, 0x0, 0x0, 0x80, 0x80, 0x0, 
        0x80, 0x0, 0x0, 0x0, 0x80, 0x0, 0x80, 0x0, 0x80, 0x80, 0x0, 
        0x0, 0xC0, 0xC0, 0xC0, 0x0, 0x80, 0x80, 0x80, 0x0, 0x0, 0x0,
        0xFF, 0x0, 0x0, 0xFF, 0x0, 0x0, 0x0, 0xFF, 0xFF, 0x0, 0xFF, 
        0x0, 0x0, 0x0, 0xFF, 0x0, 0xFF, 0x0, 0xFF, 0xFF, 0x0, 0x0, 
        0xFF, 0xFF, 0xFF, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 
        0x0, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x0, 0x0, 
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x0, 0x0, 0xFF, 0xFF, 
        0xFF, 0xFF, 0xFF, 0xF0, 0x0, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 
        0xFF, 0xF0, 0x0, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 
        0x0, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x0, 0x0, 
        0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF0, 0x0, 0x0, 0xFF, 0xFF, 
        0xFF, 0xFF, 0xFF, 0xF0, 0x0, 0x0, 0xFF, 0xFF, 0xFF, 0xFF, 
        0xFF, 0xF0, 0x0, 0x0};
    #endregion

    private Bitmap blank;
    private Bitmap x;
    private Bitmap o;
    private string xString = "X's turn";
    private string oString = "O's turn";
    private string gameOverString = "Game
 Over";
    private int bitmapPadding = 6;

    private void InitializeDataGridView(object
 sender,
        EventArgs e)
    {
        this.Panel1.SuspendLayout();
        this.SuspendLayout();

        ConfigureForm();
        SizeGrid();
        CreateColumns();
        CreateRows();

        this.Panel1.ResumeLayout(false);
        this.ResumeLayout(false);
    }

    private void ConfigureForm()
    {
        AutoSize = true;
        turn.Size = new System.Drawing.Size(75, 34);
        turn.TextAlign = ContentAlignment.MiddleLeft;
        turn.Text = xString;

        Panel1.Location = new System.Drawing.Point(0, 8);
        Panel1.Size = new System.Drawing.Size(120, 196);
        Panel1.FlowDirection = FlowDirection.TopDown;

        ClientSize = new System.Drawing.Size(355, 200);
        Controls.Add(this.Panel1);
        Text = "TicTacToe";

        dataGridView1 = new System.Windows.Forms.DataGridView();
        dataGridView1.Location = new Point(120, 0);
        dataGridView1.AllowUserToAddRows = false;
        dataGridView1.CellClick += new
            DataGridViewCellEventHandler(dataGridView1_CellClick);
        dataGridView1.CellMouseEnter += new
            DataGridViewCellEventHandler(dataGridView1_CellMouseEnter);
        dataGridView1.CellMouseLeave += new
            DataGridViewCellEventHandler(dataGridView1_CellMouseLeave);

        Controls.Add(dataGridView1);
    }

    private void SetupButtons()
    {
        Button1.AutoSize = true;
        SetupButton(Button1, "Restart", new EventHandler(Reset));
        Panel1.Controls.Add(turn);
        SetupButton(Button2, "Increase Cell Size", new
 EventHandler(MakeCellsLarger));
        SetupButton(Button3, "Stretch Images", new EventHandler(Stretch));
        SetupButton(Button4, "Zoom Images", new EventHandler(ZoomToImage));
        SetupButton(Button5, "Normal Images", new EventHandler(NormalImage));
    }

    private void SetupButton(Button button,
 string buttonLabel, EventHandler handler)
    {
        Panel1.Controls.Add(button);
        button.Text = buttonLabel;
        button.AutoSize = true;
        button.Click += handler;
    }

    private void CreateColumns()
    {
        DataGridViewImageColumn imageColumn;
        int columnCount = 0;
        do
        {
            Bitmap unMarked = blank;
            imageColumn = new DataGridViewImageColumn();

            //Add twice the padding for the left and 
            //right sides of the cell.
            imageColumn.Width = x.Width + 2 * bitmapPadding + 1;

            imageColumn.Image = unMarked;
            dataGridView1.Columns.Add(imageColumn);
            columnCount = columnCount + 1;
        }
        while (columnCount < 3);
    }

    private void CreateRows()
    {
        dataGridView1.Rows.Add();
        dataGridView1.Rows.Add();
        dataGridView1.Rows.Add();
    }

    private void SizeGrid()
    {
        dataGridView1.ColumnHeadersVisible = false;
        dataGridView1.RowHeadersVisible = false;
        dataGridView1.AllowUserToResizeColumns = false;;
        dataGridView1.AllowUserToResizeRows = false;
        dataGridView1.BorderStyle = BorderStyle.None;

        //Add twice the padding for the top of the cell 
        //and the bottom.
        dataGridView1.RowTemplate.Height = x.Height +
            2 * bitmapPadding + 1;

        dataGridView1.AutoSize = true;
    }

    private void Reset(object sender, System.EventArgs
 e)
    {
        dataGridView1.Dispose();
        InitializeDataGridView(null, null);
    }

    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 void dataGridView1_CellMouseEnter(object
 sender,
        DataGridViewCellEventArgs e)
    {
        Bitmap markingUnderMouse = (Bitmap)dataGridView1.
               Rows[e.RowIndex].
               Cells[e.ColumnIndex].Value;

        if (markingUnderMouse == blank)
        {
            dataGridView1.Cursor = Cursors.Default;
        }
        else if (markingUnderMouse == o ||
 markingUnderMouse == x)
        {
            dataGridView1.Cursor = Cursors.No;
            ToolTip(e, true);
        }
    }

    private void ToolTip(DataGridViewCellEventArgs
 e, bool showTip)
    {
        DataGridViewImageCell cell = (DataGridViewImageCell)
            dataGridView1
            .Rows[e.RowIndex].Cells[e.ColumnIndex];
        DataGridViewImageColumn imageColumn =
            (DataGridViewImageColumn)
            dataGridView1.Columns[cell.ColumnIndex];

        if (showTip) cell.ToolTipText = imageColumn.Description;
        else { cell.ToolTipText = String.Empty; }
    }

    private void dataGridView1_CellMouseLeave(object
 sender,
        DataGridViewCellEventArgs e)
    {
        ToolTip(e, false);
        dataGridView1.Cursor = Cursors.Default;
    }

    private void Stretch(object sender, EventArgs
 e)
    {
        foreach (DataGridViewImageColumn column in
            dataGridView1.Columns)
        {
            column.ImageLayout = DataGridViewImageCellLayout.Stretch;
            column.Description = "Stretched";
        }
    }

    private void ZoomToImage(object sender,
 EventArgs e)
    {

        foreach (DataGridViewImageColumn column in
            dataGridView1.Columns)
        {
            column.ImageLayout = DataGridViewImageCellLayout.Zoom;
            column.Description = "Zoomed";
        }
    }

    private void NormalImage(object sender,
 EventArgs e)
    {

        foreach (DataGridViewImageColumn column in
            dataGridView1.Columns)
        {
            column.ImageLayout = DataGridViewImageCellLayout.Normal;
            column.Description = "Normal";
        }
    }

    private void MakeCellsLarger(object sender,
 EventArgs e)
    {
        foreach (DataGridViewImageColumn column in
            dataGridView1.Columns)
        {
            column.Width = column.Width * 2;
        }
        foreach (DataGridViewRow row in dataGridView1.Rows)
        {
            if (row.IsNewRow) break;
            row.Height = (int)(row.Height * 1.5);
        }
    }

    private bool IsAWin()
    {
        if (ARowIsSame() || AColumnIsSame() || ADiagonalIsSame())
            return true;
        else return false;
    }

    private bool ARowIsSame()
    {
        Bitmap marking = null;

        foreach (DataGridViewRow row in dataGridView1.Rows)
        {
            if (row.IsNewRow) break;
            marking = (Bitmap)row.Cells[0].Value;
            if (marking != blank)
            {
                if (marking == row.Cells[1].Value &&
                    marking == row.Cells[2].Value) return true;
            }
        }
        return false;
    }

    private bool AColumnIsSame()
    {
        int columnIndex = 0;
        Bitmap marking;
        do
        {
            marking = (Bitmap)
                dataGridView1.Rows[0].Cells[columnIndex].Value;
            if (marking != blank)
            {
                if (marking == (Bitmap)dataGridView1.Rows[1]
                    .Cells[columnIndex].Value
                    && marking == (Bitmap)dataGridView1.Rows[2].
                    Cells[columnIndex].Value) return true;
            }
            columnIndex = columnIndex + 1;
        }
        while (columnIndex < dataGridView1.Columns.GetColumnCount(
            DataGridViewElementStates.Visible));
        return false;
    }

    private bool ADiagonalIsSame()
    {
        if (LeftToRightDiagonalIsSame()) { return
 true; }
        if (RightToLeftDiagonalIsSame()) { return
 true; }
        return false;
    }

    private bool LeftToRightDiagonalIsSame()
    {
        return IsDiagonalSame(0, 2);
    }

    private bool RightToLeftDiagonalIsSame()
    {
        return IsDiagonalSame(2, 0);
    }

    private bool IsDiagonalSame(int
 startingColumn, int lastColumn)
    {
        Bitmap marking = (Bitmap)dataGridView1.Rows[0]
            .Cells[startingColumn].Value;

        if (marking == blank) return false;
        if (marking == dataGridView1.Rows[1].Cells[1]
            .Value && marking == dataGridView1.Rows[2]
            .Cells[lastColumn].Value) return true;

        return false;
    }

    private void ToggleTurn()
    {
        if (turn.Text.Equals(xString)) { turn.Text = oString;
 }
        else { turn.Text = xString; }
    }

    private bool IsOsTurn()
    {
        if (turn.Text.Equals(oString)) return
 true;
        return false;
    }

    [STAThread]
    public static void Main()
    {
        Application.Run(new TicTacToe());
    }

}
継承階層継承階層
System.Object
   System.Windows.Forms.DataGridViewElement
     System.Windows.Forms.DataGridViewBand
       System.Windows.Forms.DataGridViewColumn
        System.Windows.Forms.DataGridViewImageColumn
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridViewImageColumn メンバ
System.Windows.Forms 名前空間
DataGridView クラス
DataGridViewColumn クラス
DataGridViewRow
DataGridViewImageCell クラス
DataGridViewImageCell.ValueIsIcon
Image
Icon
DataGridViewColumn.SortMode プロパティ

DataGridViewImageColumn コンストラクタ ()

メモ : このコンストラクタは、.NET Framework version 2.0 で新しく追加されたものです。

DataGridViewImageColumn クラスの新しいインスタンスを初期化し、セル値を Image 型にして使用するよう構成します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Dim instance As New DataGridViewImageColumn
public DataGridViewImageColumn ()
public:
DataGridViewImageColumn ()
public DataGridViewImageColumn ()
public function DataGridViewImageColumn ()
解説解説

このコンストラクタは、valuesAreIcons パラメータの値を false に設定して DataGridViewImageColumn(Boolean) を呼び出します。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridViewImageColumn クラス
DataGridViewImageColumn メンバ
System.Windows.Forms 名前空間
DataGridView クラス
DataGridViewImageCell クラス
Image

DataGridViewImageColumn コンストラクタ (Boolean)

メモ : このコンストラクタは、.NET Framework version 2.0 で新しく追加されたものです。

DataGridViewImageColumn クラスの新しいインスタンスを初期化し、オプションでセル値を Icon にして使用するよう構成します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Sub New ( _
    valuesAreIcons As Boolean _
)
Dim valuesAreIcons As Boolean

Dim instance As New DataGridViewImageColumn(valuesAreIcons)
public DataGridViewImageColumn (
    bool valuesAreIcons
)
public:
DataGridViewImageColumn (
    bool valuesAreIcons
)
public DataGridViewImageColumn (
    boolean valuesAreIcons
)
public function DataGridViewImageColumn (
    valuesAreIcons : boolean
)

パラメータ

valuesAreIcons

この列に含まれるセルの Value プロパティが Icon 型の値に設定されることを示す場合は true。Image 型の値に設定されることを示す場合は false。

解説解説

このコンストラクタは、次のプロパティを設定することによって列を初期化します。

プロパティ

値

CellTemplate

ValueIsIcon プロパティが valuesAreIcons パラメータの値に初期化された新しい DataGridViewImageCell。

ValuesAreIcons

valuesAreIcons パラメータの値。

DefaultCellStyle プロパティによって返される DataGridViewCellStyle オブジェクトの Alignment プロパティ。

DataGridViewContentAlignment.MiddleCenter

DefaultCellStyle プロパティによって返される DataGridViewCellStyle オブジェクトの NullValue プロパティ。

valuesAreIcons が true の場合は、Icon 型の標準のエラー グラフィック。valuesAreIcons が false の場合は、Bitmap 型の標準のエラー グラフィック。

Icon 型のセル値のアルファ チャネルが正確に描画されるようにするには、このコンストラクタの valuesAreIcons パラメータ値を true に設定して使用します。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataGridViewImageColumn クラス
DataGridViewImageColumn メンバ
System.Windows.Forms 名前空間
DataGridView クラス
DataGridViewCell.Value プロパティ
ValuesAreIcons
CellTemplate
DataGridViewImageCell クラス
DataGridViewImageCell.ValueIsIcon
DefaultCellStyle
DataGridViewCellStyle クラス
DataGridViewCellStyle.Alignment プロパティ
DataGridViewCellStyle.NullValue プロパティ
Icon
Bitmap
Image

DataGridViewImageColumn コンストラクタ

DataGridViewImageColumn クラスの新しいインスタンスを初期化します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
DataGridViewImageColumn () DataGridViewImageColumn クラスの新しいインスタンスを初期化し、セル値を Image 型にして使用するよう構成します。
DataGridViewImageColumn (Boolean) DataGridViewImageColumn クラスの新しいインスタンスを初期化し、オプションでセル値を Icon にして使用するよう構成します。
参照参照

関連項目

DataGridViewImageColumn クラス
DataGridViewImageColumn メンバ
System.Windows.Forms 名前空間
DataGridView クラス
DataGridViewImageCell クラス
Image

DataGridViewImageColumn プロパティ


パブリック プロパティパブリック プロパティ

( プロテクト プロパティ も参照)
  名前 説明
パブリック プロパティ AutoSizeMode  列の幅を自動的に調整するときに使用するモードを取得または設定します。 ( DataGridViewColumn から継承されます。)
パブリック プロパティ CellTemplate オーバーライドされます。 新しいセルの作成に使用するテンプレートを取得または設定します。
パブリック プロパティ CellType  セル テンプレートのランタイム型を取得します。 ( DataGridViewColumn から継承されます。)
パブリック プロパティ ContextMenuStrip  列のショートカット メニューを取得または設定します。 ( DataGridViewColumn から継承されます。)
パブリック プロパティ DataGridView  この要素に関連付けられている DataGridView コントロールを取得します。 ( DataGridViewElement から継承されます。)
パブリック プロパティ DataPropertyName  DataGridViewColumn がバインドされている、データ ソース プロパティの名前またはデータベースの列の名前を取得または設定します。 ( DataGridViewColumn から継承されます。)
パブリック プロパティ DefaultCellStyle オーバーライドされます。 列の既定のセル スタイルを取得または設定します。
パブリック プロパティ DefaultHeaderCellType  既定のヘッダー セルのランタイム型を取得または設定します。 ( DataGridViewBand から継承されます。)
パブリック プロパティ Description 列のイメージを説明する文字列を取得または設定します。
パブリック プロパティ Displayed  バンドが現在画面に表示されているかどうかを示す値を取得します。 ( DataGridViewBand から継承されます。)
パブリック プロパティ DisplayIndex  現在表示されている列を基準とした列の表示順序を設定または取得します。 ( DataGridViewColumn から継承されます。)
パブリック プロパティ DividerWidth  列の区分線の幅 (ピクセル数) を取得または設定します。 ( DataGridViewColumn から継承されます。)
パブリック プロパティ FillWeight  列が、コントロール内の他の塗りつぶしモードの列の幅を基準とする塗りつぶしモードの場合、列の幅を表す値を取得または設定します。 ( DataGridViewColumn から継承されます。)
パブリック プロパティ Frozen  ユーザーが DataGridView コントロールを水平方向にスクロールしたときに列が移動するかどうかを示す値を取得または設定します。 ( DataGridViewColumn から継承されます。)
パブリック プロパティ HasDefaultCellStyle  DefaultCellStyle プロパティが設定されているかどうかを示す値を取得します。 ( DataGridViewBand から継承されます。)
パブリック プロパティ HeaderCell  列ヘッダーを表す DataGridViewColumnHeaderCell を取得または設定します。 ( DataGridViewColumn から継承されます。)
パブリック プロパティ HeaderText  列のヘッダー セルのキャプション テキストを取得または設定します。 ( DataGridViewColumn から継承されます。)
パブリック プロパティ Icon セルの Value プロパティが設定されておらず、セルの ValueIsIcon プロパティが true に設定されている場合に、この列のセルに表示されるアイコンを取得または設定します。
パブリック プロパティ Image セルの Value プロパティが設定されておらず、セルの ValueIsIcon プロパティが false に設定されている場合に、この列のセルに表示されるイメージを取得または設定します。
パブリック プロパティ ImageLayout この列のセルのイメージのレイアウトを取得または設定します。
パブリック プロパティ Index  DataGridView コントロール内のバンドの相対位置を取得します。 ( DataGridViewBand から継承されます。)
パブリック プロパティ InheritedAutoSizeMode  列に対して有効なサイズ変更モードを取得します。 ( DataGridViewColumn から継承されます。)
パブリック プロパティ InheritedStyle  列に現在適用されているセル スタイルを取得します。 ( DataGridViewColumn から継承されます。)
パブリック プロパティ IsDataBound  列がデータ ソースにバインドされているかどうかを示す値を取得します。 ( DataGridViewColumn から継承されます。)
パブリック プロパティ MinimumWidth  列の最小幅をピクセル単位で取得または設定します。 ( DataGridViewColumn から継承されます。)
パブリック プロパティ Name  列の名前を取得または設定します。 ( DataGridViewColumn から継承されます。)
パブリック プロパティ ReadOnly  ユーザーが列のセルを編集できるかどうかを示す値を取得または設定します。 ( DataGridViewColumn から継承されます。)
パブリック プロパティ Resizable  列のサイズを変更できるかどうかを示す値を取得または設定します。 ( DataGridViewColumn から継承されます。)
パブリック プロパティ Selected  バンドが、選択されたユーザー インターフェイス (UI) 状態かどうかを示す値を取得または設定します。 ( DataGridViewBand から継承されます。)
パブリック プロパティ Site  列のサイトを取得または設定します。 ( DataGridViewColumn から継承されます。)
パブリック プロパティ SortMode  列の並べ替えモードを取得または設定します。 ( DataGridViewColumn から継承されます。)
パブリック プロパティ State  要素のユーザー インターフェイス (UI) の状態を取得します。 ( DataGridViewElement から継承されます。)
パブリック プロパティ Tag  バンドに関連付けられているデータを含むオブジェクトを取得または設定します。 ( DataGridViewBand から継承されます。)
パブリック プロパティ ToolTipText  ツールヒントに使用されるテキストを取得または設定します。 ( DataGridViewColumn から継承されます。)
パブリック プロパティ ValuesAreIcons この列に含まれるセルに Icon 値を表示するかどうかを示す値を取得または設定します。
パブリック プロパティ ValueType  列のセルの値のデータ型を取得または設定します。 ( DataGridViewColumn から継承されます。)
パブリック プロパティ Visible  列を表示するかどうかを示す値を取得または設定します。 ( DataGridViewColumn から継承されます。)
パブリック プロパティ Width  列の現在の幅を取得または設定します。 ( DataGridViewColumn から継承されます。)
プロテクト プロパティプロテクト プロパティ
  名前 説明
プロテクト プロパティ HeaderCellCore  DataGridViewBand のヘッダー セルを取得または設定します。 ( DataGridViewBand から継承されます。)
プロテクト プロパティ IsRow  バンドが行を表すかどうかを示す値を取得します。 ( DataGridViewBand から継承されます。)
参照参照

関連項目

DataGridViewImageColumn クラス
System.Windows.Forms 名前空間
DataGridView クラス
DataGridViewColumn クラス
DataGridViewRow
DataGridViewImageCell クラス
DataGridViewImageCell.ValueIsIcon
Image
Icon
DataGridViewColumn.SortMode プロパティ

DataGridViewImageColumn メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
  名前 説明
プロテクト メソッド Dispose  オーバーロードされます。 DataGridViewColumn によって使用されているすべてのリソースを解放します。 ( DataGridViewColumn から継承されます。)
プロテクト メソッド Finalize  バンドに関連付けられたリソースを解放します。 ( DataGridViewBand から継承されます。)
プロテクト メソッド MemberwiseClone  現在の Object の簡易コピーを作成します。 ( Object から継承されます。)
プロテクト メソッド OnDataGridViewChanged  バンドが別の DataGridView に関連付けられている場合に呼び出されます。 ( DataGridViewBand から継承されます。)
プロテクト メソッド RaiseCellClick  DataGridView.CellClick イベントを発生させます。 ( DataGridViewElement から継承されます。)
プロテクト メソッド RaiseCellContentClick  DataGridView.CellContentClick イベントを発生させます。 ( DataGridViewElement から継承されます。)
プロテクト メソッド RaiseCellContentDoubleClick  DataGridView.CellContentDoubleClick イベントを発生させます。 ( DataGridViewElement から継承されます。)
プロテクト メソッド RaiseCellValueChanged  DataGridView.CellValueChanged イベントを発生させます。 ( DataGridViewElement から継承されます。)
プロテクト メソッド RaiseDataError  DataGridView.DataError イベントを発生させます。 ( DataGridViewElement から継承されます。)
プロテクト メソッド RaiseMouseWheel  Control.MouseWheel イベントを発生させます。 ( DataGridViewElement から継承されます。)
参照参照

関連項目

DataGridViewImageColumn クラス
System.Windows.Forms 名前空間
DataGridView クラス
DataGridViewColumn クラス
DataGridViewRow
DataGridViewImageCell クラス
DataGridViewImageCell.ValueIsIcon
Image
Icon
DataGridViewColumn.SortMode プロパティ

DataGridViewImageColumn メンバ

DataGridViewImageCell オブジェクトのコレクションをホストします。

DataGridViewImageColumn データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド DataGridViewImageColumn オーバーロードされます。 DataGridViewImageColumn クラスの新しいインスタンスを初期化します。
パブリック プロパティパブリック プロパティ
( プロテクト プロパティ も参照)
  名前 説明
パブリック プロパティ AutoSizeMode  列の幅を自動的に調整するときに使用するモードを取得または設定します。(DataGridViewColumn から継承されます。)
パブリック プロパティ CellTemplate オーバーライドされます。 新しいセルの作成に使用するテンプレートを取得または設定します。
パブリック プロパティ CellType  セル テンプレートのランタイム型を取得します。(DataGridViewColumn から継承されます。)
パブリック プロパティ ContextMenuStrip  列のショートカット メニューを取得または設定します。(DataGridViewColumn から継承されます。)
パブリック プロパティ DataGridView  この要素に関連付けられている DataGridView コントロールを取得します。(DataGridViewElement から継承されます。)
パブリック プロパティ DataPropertyName  DataGridViewColumn がバインドされている、データ ソース プロパティの名前またはデータベースの列の名前を取得または設定します。(DataGridViewColumn から継承されます。)
パブリック プロパティ DefaultCellStyle オーバーライドされます。 列の既定のセル スタイルを取得または設定します。
パブリック プロパティ DefaultHeaderCellType  既定のヘッダー セルのランタイム型を取得または設定します。(DataGridViewBand から継承されます。)
パブリック プロパティ Description 列のイメージを説明する文字列を取得または設定します。
パブリック プロパティ Displayed  バンドが現在画面に表示されているかどうかを示す値を取得します。 (DataGridViewBand から継承されます。)
パブリック プロパティ DisplayIndex  現在表示されている列を基準とした列の表示順序を設定または取得します。(DataGridViewColumn から継承されます。)
パブリック プロパティ DividerWidth  列の区分線の幅 (ピクセル数) を取得または設定します。(DataGridViewColumn から継承されます。)
パブリック プロパティ FillWeight  列が、コントロール内の他の塗りつぶしモードの列の幅を基準とする塗りつぶしモードの場合、列の幅を表す値を取得または設定します。(DataGridViewColumn から継承されます。)
パブリック プロパティ Frozen  ユーザーが DataGridView コントロールを水平方向にスクロールしたときに列が移動するかどうかを示す値を取得または設定します。(DataGridViewColumn から継承されます。)
パブリック プロパティ HasDefaultCellStyle  DefaultCellStyle プロパティが設定されているかどうかを示す値を取得します。 (DataGridViewBand から継承されます。)
パブリック プロパティ HeaderCell  列ヘッダーを表す DataGridViewColumnHeaderCell を取得または設定します。(DataGridViewColumn から継承されます。)
パブリック プロパティ HeaderText  列のヘッダー セルのキャプション テキストを取得または設定します。(DataGridViewColumn から継承されます。)
パブリック プロパティ Icon セルの Value プロパティが設定されておらず、セルの ValueIsIcon プロパティが true に設定されている場合に、この列のセルに表示されるアイコンを取得または設定します。
パブリック プロパティ Image セルの Value プロパティが設定されておらず、セルの ValueIsIcon プロパティが false に設定されている場合に、この列のセルに表示されるイメージを取得または設定します。
パブリック プロパティ ImageLayout この列のセルのイメージのレイアウトを取得または設定します。
パブリック プロパティ Index  DataGridView コントロール内のバンドの相対位置を取得します。(DataGridViewBand から継承されます。)
パブリック プロパティ InheritedAutoSizeMode  列に対して有効なサイズ変更モードを取得します。(DataGridViewColumn から継承されます。)
パブリック プロパティ InheritedStyle  列に現在適用されているセル スタイルを取得します。(DataGridViewColumn から継承されます。)
パブリック プロパティ IsDataBound  列がデータ ソースにバインドされているかどうかを示す値を取得します。(DataGridViewColumn から継承されます。)
パブリック プロパティ MinimumWidth  列の最小幅をピクセル単位で取得または設定します。(DataGridViewColumn から継承されます。)
パブリック プロパティ Name  列の名前を取得または設定します。(DataGridViewColumn から継承されます。)
パブリック プロパティ ReadOnly  ユーザーが列のセルを編集できるかどうかを示す値を取得または設定します。(DataGridViewColumn から継承されます。)
パブリック プロパティ Resizable  列のサイズを変更できるかどうかを示す値を取得または設定します。(DataGridViewColumn から継承されます。)
パブリック プロパティ Selected  バンドが、選択されたユーザー インターフェイス (UI) 状態かどうかを示す値を取得または設定します。(DataGridViewBand から継承されます。)
パブリック プロパティ Site  列のサイトを取得または設定します。(DataGridViewColumn から継承されます。)
パブリック プロパティ SortMode  列の並べ替えモードを取得または設定します。(DataGridViewColumn から継承されます。)
パブリック プロパティ State  要素のユーザー インターフェイス (UI) の状態を取得します。(DataGridViewElement から継承されます。)
パブリック プロパティ Tag  バンドに関連付けられているデータを含むオブジェクトを取得または設定します。(DataGridViewBand から継承されます。)
パブリック プロパティ ToolTipText  ツールヒントに使用されるテキストを取得または設定します。(DataGridViewColumn から継承されます。)
パブリック プロパティ ValuesAreIcons この列に含まれるセルに Icon 値を表示するかどうかを示す値を取得または設定します。
パブリック プロパティ ValueType  列のセルの値のデータ型を取得または設定します。(DataGridViewColumn から継承されます。)
パブリック プロパティ Visible  列を表示するかどうかを示す値を取得または設定します。(DataGridViewColumn から継承されます。)
パブリック プロパティ Width  列の現在の幅を取得または設定します。(DataGridViewColumn から継承されます。)
プロテクト プロパティプロテクト プロパティ
  名前 説明
プロテクト プロパティ HeaderCellCore  DataGridViewBand のヘッダー セルを取得または設定します。(DataGridViewBand から継承されます。)
プロテクト プロパティ IsRow  バンドが行を表すかどうかを示す値を取得します。(DataGridViewBand から継承されます。)
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
  名前 説明
プロテクト メソッド Dispose  オーバーロードされます。 DataGridViewColumn によって使用されているすべてのリソースを解放します。 (DataGridViewColumn から継承されます。)
プロテクト メソッド Finalize  バンドに関連付けられたリソースを解放します。 (DataGridViewBand から継承されます。)
プロテクト メソッド MemberwiseClone  現在の Object の簡易コピーを作成します。 (Object から継承されます。)
プロテクト メソッド OnDataGridViewChanged  バンドが別の DataGridView に関連付けられている場合に呼び出されます。 (DataGridViewBand から継承されます。)
プロテクト メソッド RaiseCellClick  DataGridView.CellClick イベントを発生させます。 (DataGridViewElement から継承されます。)
プロテクト メソッド RaiseCellContentClick  DataGridView.CellContentClick イベントを発生させます。 (DataGridViewElement から継承されます。)
プロテクト メソッド RaiseCellContentDoubleClick  DataGridView.CellContentDoubleClick イベントを発生させます。 (DataGridViewElement から継承されます。)
プロテクト メソッド RaiseCellValueChanged  DataGridView.CellValueChanged イベントを発生させます。 (DataGridViewElement から継承されます。)
プロテクト メソッド RaiseDataError  DataGridView.DataError イベントを発生させます。 (DataGridViewElement から継承されます。)
プロテクト メソッド RaiseMouseWheel  Control.MouseWheel イベントを発生させます。 (DataGridViewElement から継承されます。)
パブリック イベントパブリック イベント
  名前 説明
パブリック イベント Disposed  DataGridViewColumn が破棄されたときに発生します。(DataGridViewColumn から継承されます。)
参照参照

関連項目

DataGridViewImageColumn クラス
System.Windows.Forms 名前空間
DataGridView クラス
DataGridViewColumn クラス
DataGridViewRow
DataGridViewImageCell クラス
DataGridViewImageCell.ValueIsIcon
Image
Icon
DataGridViewColumn.SortMode プロパティ



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「DataGridViewImageColumn」の関連用語

DataGridViewImageColumnのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DataGridViewImageColumnのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS