teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

よくわからない

2020/04/22 12:45

投稿

tear213
tear213

スコア2

title CHANGED
File without changes
body CHANGED
@@ -3,24 +3,52 @@
3
3
 
4
4
 
5
5
  ### 発生している問題・エラーメッセージ
6
+ objDataTable.Rows.Add(objRow);
6
- 1列目しか追加できない。
7
+ でテーブルにRowDataを追加したいのだが、1列目しかデータが入らない。
7
8
 
8
9
  System.Windows.Data Error: 40 : BindingExpression path error:
9
10
 
10
11
  ### 該当のソースコード
11
12
 
12
13
  ```C#
14
+ public void InitializeView()
15
+ {
16
+ DataTable objDataTable = new DataTable("Table");
17
+ Module objModule = (Module)((MainView)this.Owner).ModuleList[Config.GetInstance().MEASUREMENT_MODE];
18
+ MethodInfo mi = objModule.ModuleType.GetMethod("GetConfig", Type.EmptyTypes);
19
+ object objConfigResult = mi.Invoke(objModule.ModuleConstructorObject, null);
20
+ SortedList<int, KeyValuePair<string, string>> lstConfigResult = (SortedList<int, KeyValuePair<string, string>>)objConfigResult;
21
+ KeyValuePair<string, string> kvConfigResult;
22
+ for (int intIndex = 0; intIndex < lstConfigResult.Count; intIndex++)
23
+ {
24
+ kvConfigResult = lstConfigResult[intIndex];
25
+ objDataTable.Columns.Add(kvConfigResult.Key);
26
+ }
27
+
28
+ mi = objModule.ModuleType.GetMethod("GetMeasurementResult", Type.EmptyTypes);
29
+ List<List<string>> lstMeasurementResult = (List<List<string>>)mi.Invoke(objModule.ModuleConstructorObject, null);
13
30
  foreach (List<string> lstResult in lstMeasurementResult)
14
31
  {
15
32
  DataRow objRow = objDataTable.NewRow();
16
33
  int intIndex = 0;
17
34
  foreach (string strResult in lstResult)
18
35
  {
36
+ string strData = strResult.Remove(0, strResult.IndexOf(':') + 1);
19
- objRow[objDataTable.Columns[intIndex].ColumnName] = strResult;
37
+ objRow[objDataTable.Columns[intIndex].ColumnName] = strData;
20
38
  intIndex++;
21
39
  }
22
40
  objDataTable.Rows.Add(objRow);
23
41
  }
24
42
  this.DataContext = objDataTable;
43
+ }
25
44
 
45
+
26
- ```
46
+ ```
47
+ ```xaml
48
+ <!--設定内容-->
49
+ <Grid>
50
+ <DataGrid ItemsSource="{Binding}" AutoGenerateColumns="True" />
51
+ </Grid>
52
+
53
+ ```
54
+ 自分でもよくわかっていないです。すみません。