回答編集履歴

2

コードを読みやすいように変更

2016/01/26 06:40

投稿

u.-_-.u
u.-_-.u

スコア59

test CHANGED
@@ -14,6 +14,8 @@
14
14
 
15
15
  ・セルの取得
16
16
 
17
+ ```lang-C言語
18
+
17
19
  foreach (DataGridViewCell c in DataGridView1.SelectedCells)
18
20
 
19
21
  {
@@ -22,9 +24,11 @@
22
24
 
23
25
  }
24
26
 
25
-
27
+ ```
26
28
 
27
29
  ・行を表示
30
+
31
+ ```lang-C言語
28
32
 
29
33
  Console.WriteLine("選択されている行");
30
34
 
@@ -36,9 +40,11 @@
36
40
 
37
41
  }
38
42
 
39
-
43
+ ```
40
44
 
41
45
  ・列を表示
46
+
47
+ ```lang-C言語
42
48
 
43
49
  Console.WriteLine("選択されている列");
44
50
 
@@ -50,30 +56,34 @@
50
56
 
51
57
  }
52
58
 
53
-
59
+ ```
54
60
 
55
61
  ■例を記載しておきます。
56
62
 
63
+ ```lang-C言語
64
+
57
65
  private void dataGridView1_SelectionChanged(object sender, EventArgs e)
58
66
 
59
- {
67
+ {
60
68
 
61
- foreach (DataGridViewCell c in dataGridView1.SelectedCells)
69
+ foreach (DataGridViewCell c in dataGridView1.SelectedCells)
62
70
 
63
- {
71
+ {
64
72
 
65
- Console.WriteLine("{0}, {1}", c.ColumnIndex, c.RowIndex);
73
+ Console.WriteLine("{0}, {1}", c.ColumnIndex, c.RowIndex);
66
74
 
67
75
 
68
76
 
69
- if(c.ColumnIndex == 1)
77
+ if(c.ColumnIndex == 1)
70
78
 
71
- {
79
+ {
72
80
 
73
- Console.WriteLine("2列目です");
81
+ Console.WriteLine("2列目です");
74
82
 
75
- }
83
+ }
76
84
 
77
- }
85
+ }
78
86
 
79
- }
87
+ }
88
+
89
+ ```

1

インデントの修正

2016/01/26 06:40

投稿

u.-_-.u
u.-_-.u

スコア59

test CHANGED
@@ -56,22 +56,24 @@
56
56
 
57
57
  private void dataGridView1_SelectionChanged(object sender, EventArgs e)
58
58
 
59
- {
59
+ {
60
60
 
61
- foreach (DataGridViewCell c in dataGridView1.SelectedCells)
61
+ foreach (DataGridViewCell c in dataGridView1.SelectedCells)
62
62
 
63
- {
63
+ {
64
64
 
65
- Console.WriteLine("{0}, {1}", c.ColumnIndex, c.RowIndex);
65
+ Console.WriteLine("{0}, {1}", c.ColumnIndex, c.RowIndex);
66
66
 
67
- if(c.ColumnIndex == 1)
68
67
 
69
- {
70
68
 
71
- Console.WriteLine("2列目です");
69
+ if(c.ColumnIndex == 1)
72
70
 
73
- }
71
+ {
74
72
 
75
- }
73
+ Console.WriteLine("2列目です");
76
74
 
77
- }
75
+ }
76
+
77
+ }
78
+
79
+ }