回答編集履歴

2

``CurrentCell`` は共有行を非共有行にすることがあるので、``CurrentCellAddress`` を使用するよう修正

2016/01/12 07:08

投稿

alg
alg

スコア2019

test CHANGED
@@ -1,14 +1,10 @@
1
- ``CurrentCell`` ですかね。
1
+ ``CurrentCellAddress`` ですかね。
2
2
 
3
3
 
4
4
 
5
5
  ```csharp
6
6
 
7
- if (dataGridView1.CurrentCell != null &&
7
+ if (dataGridView1.CurrentCellAddress.X == 1 && dataGridView1.CurrentCellAddress.Y == 1)
8
-
9
- dataGridView1.CurrentCell.ColumnIndex == 1 &&
10
-
11
- dataGridView1.CurrentCell.RowIndex == 1)
12
8
 
13
9
  {
14
10
 

1

``CurrentCell`` が null だった場合も考慮

2016/01/12 07:08

投稿

alg
alg

スコア2019

test CHANGED
@@ -4,7 +4,11 @@
4
4
 
5
5
  ```csharp
6
6
 
7
+ if (dataGridView1.CurrentCell != null &&
8
+
7
- if (dataGridView1.CurrentCell.ColumnIndex == 1 && dataGridView1.CurrentCell.RowIndex == 1)
9
+ dataGridView1.CurrentCell.ColumnIndex == 1 &&
10
+
11
+ dataGridView1.CurrentCell.RowIndex == 1)
8
12
 
9
13
  {
10
14