using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.IO; WindowsFormsApp1 namespace {public partial class Form1: Form {public Form1 () {InitializeComponent (); } Table DataTable = new DataTable (); private void Form1_Load (object sender, EventArgs e) {} private void btn_import_Click (object sender, EventArgs e) {OpenFileDialog openFileDialog1 = new OpenFileDialog {Title = "Browse file", CheckFileExists = true, CheckPathExists = true , DefaultExt ", Filter =" txt files (* .txt) | * .txt ", FilterIndex = 2, RestoreDirectory = true, ReadOnlyChecked = true, ShowReadOnly = true,}; if (openFileDialog1.ShowDialog () == DialogResult.OK) {foreach (string file in openFileDialog1.FileNames) {textBox1. Text = openFileDialog1.FileName; Helper.file = textBox1.Text;} dataGridView1.DataSource = Helper.DataTableFromTextFile (textBox1.Text);}} private empty label1_Click (object sender, EventArgs e) {}}} [/ CODE ] [CODE lang = "csharp" title = "Helper"] using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Data; using System.IO; WindowsFormsApp1 namespace {Class Aid {public static string file; public static DataTable DataTableFromTextFile (string location, char delimiter = '\ t') {DataTable result; location = file; string [] linearay = File.ReadAllLines (location); result = FromDataTable (linear, delimiter); return result; } Private static DataTable FromDataTable (string [] linearay, char delimiter) {DataTable dt = new DataTable (); AddCoulumnToTable (linear, delimiter, ref dt); AddRowToTable (linear, delimiter, ref dt); return dt; } private static void AddRowToTable (string [] Values, char delimiter, ref DataTable dt) {for (int i = 0; i <Values.Length; i ++) {string [] values = .Split values (delimiter); DataRow dr = dt.NewRow (); for (int j = 0; j <values.Length; j ++) {dr [j] = values [j]; } dt.Rows.Add (dr); }} private static void AddCoulumnToTable (string [] columnCollectioi, char delimiter, ref DataTable dt) {string [] colones = columnCollectioi [0] .Split (delimiter); foreach (columnName string in colones) {DataColumn dc = new DataColumn (); dt.Columns.Add (dc); } } } }