1.C#のWPFで、すでにDataGrid(readOnly)がある状態
2.テキストボックスに文字列を記入
3.ボタン押下
4.DataGridのフォーカスを当てている箇所に文字列が挿入される
実現したいのは以上のような動作です。
フォーカスを当てているセルの特定や、
データの挿入方法で躓いています。
いい方法はないでしょうか?
追記
DataGridRow row = myDataGrid.ItemContainerGenerator.ContainerFromItem(myDataGrid.SelectedItem) as DataGridRow;
DataGridCell cell = myDataGrid.Columns[myDataGrid.SelectedIndex].GetCellContent(row).Parent as DataGridCell;
上の2行でフォーカスを当てているセルは特定できたと思いますが、
このセルに文字列を挿入することができません。
<DataGrid x:Name="myDataGrid" HorizontalAlignment="Left" Height="190" Margin="145,90,0,0" VerticalAlignment="Top" Width="490" SelectionChanged="DataGrid_SelectionChanged"/>
DataGrid関係のXAMLは上記だけです
あなたの回答
tips
プレビュー