How to display JSON data in a DataGridView in WinForms?

后端 未结 3 1076
隐瞒了意图╮
隐瞒了意图╮ 2020-12-14 13:26

This is the JSON data that I have:

{"testId":1,"testName":"HTML","minScore":20,"score":40,"date&qu

3条回答
  •  一整个雨季
    2020-12-14 14:19

    There's a simpler way to do this. You don't need to create a new class. Simply do:

    DataTable dataTable = (DataTable)JsonConvert.DeserializeObject(jsonString, (typeof(DataTable)));
    dataGridView.DataSource = dataTable;
    

    No need for a custom class. You'll still need Newtonsoft though.

提交回复
热议问题