@AMER SAID , Welcome to Microsoft Q&A, you could use string.split and linq method to import data from a text file into a datagridview.
private void button1_Click(object sender, EventArgs e)
{
var lines= File.ReadAllLines("test.txt");
var list = (from m in lines.ToList()
select new Example
{
id = m.Split(new string[] { ",", ":" }, StringSplitOptions.None)[1].Replace("\"", ""),
full_name = m.Split(new string[] { ",", ":" }, StringSplitOptions.None)[3].Replace("\"", ""),
}).ToList();
dataGridView1.DataSource = list;
}
public class Example
{
public string id { get; set;}
public string full_name { get; set;}
}
Result:
Best Regards,
Jack
If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.