WPFアプリケーションでデータグリッドを使用していますが、ボタンclick.Iのリスト内のすべての行の値を取得したいのですが、いくつかの方法を試しましたが、 ...WPFでDataGridからすべての行を取得する方法
private async void Save_Btn_Click(object sender, RoutedEventArgs e)
{
pojo rowdata = new pojo();
int rowcount = calendarmstrDG.Items.Count;
List<pojo> pojolist = new List<pojo>();
var rows = (calendarmstrDG).SelectedItems;
for (int i = 1; i < rowcount - 1; i++)
{
pojo sda = (pojo)calendarmstrDG.SelectedItems;
pojolist.Add(sda);
}
}
ここcalendarmstrDGはforeach
ループを使用して、すべてのアイテムの上に
public class pojo
{
public string Prefix { get; set; }
public int Year { get; set; }
public int Quarter { get; set; }
public int SerialNo { get; set; }
public string From { get; set; }
public string To { get; set; }
public string PeriodName { get; set; }
}
1.選択したアイテムにのみアクセスしています。 2.あなたのforループでは、 "i"を使用して行単位で行を選択していません。 – royalTS
正確なコードで助けてください。すべての行が必要です。 – Markz