DataGridView.CurrentCellAddress プロパティ
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
現在アクティブなセルの行インデックスおよび列インデックスを取得します。
public:
property System::Drawing::Point CurrentCellAddress { System::Drawing::Point get(); };
[System.ComponentModel.Browsable(false)]
public System.Drawing.Point CurrentCellAddress { get; }
[<System.ComponentModel.Browsable(false)>]
member this.CurrentCellAddress : System.Drawing.Point
Public ReadOnly Property CurrentCellAddress As Point
現在アクティブなセルの行インデックスおよび列インデックスを表す Point。
- 属性
次のコード例は、行描画シナリオで プロパティを CurrentCellAddress 使用する方法を示しています。 この例では、このプロパティを使用して、現在のセルの行インデックスを格納します。 ユーザーが現在のセルを別の行に変更すると、行は強制的に再描画されます。
このコードは、「方法: Windows フォーム DataGridView コントロールの行の外観をカスタマイズする」で使用できる大きな例の一部です。
// Forces the row to repaint itself when the user changes the
// current cell. This is necessary to refresh the focus rectangle.
void dataGridView1_CurrentCellChanged(object sender, EventArgs e)
{
if (oldRowIndex != -1)
{
this.dataGridView1.InvalidateRow(oldRowIndex);
}
oldRowIndex = this.dataGridView1.CurrentCellAddress.Y;
}
' Forces the row to repaint itself when the user changes the
' current cell. This is necessary to refresh the focus rectangle.
Sub dataGridView1_CurrentCellChanged(ByVal sender As Object, _
ByVal e As EventArgs) Handles dataGridView1.CurrentCellChanged
If oldRowIndex <> -1 Then
Me.dataGridView1.InvalidateRow(oldRowIndex)
End If
oldRowIndex = Me.dataGridView1.CurrentCellAddress.Y
End Sub
セルに直接アクセスせずに現在のセルの行と列を確認するには、このプロパティを使用します。 これは、共有行の共有解除を回避するのに役立ちます。 行の共有の詳細については、「Windows フォーム DataGridView コントロールを拡張するための推奨される手順」を参照してください。
製品 | バージョン |
---|---|
.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 はオープンソース プロジェクトです。 フィードバックを提供するにはリンクを選択します。