private void button2_Click(object sender, RoutedEventArgs e) { try { DataTable dt = dataTable; int colCountExpect = TheTool.getInt(txtColCount); if (dt.Columns.Contains(col_colCount) == false) { dt.Columns.Add(col_colCount); } foreach (DataRow r in dt.Rows) { int c = TheTool.CSV_countCol(r[col_path].ToString()); if (c != colCountExpect && c != 0) { r[col_colCount] = c; } else { r[col_colCount] = ""; } } setDataGrid(this.dataTable); } catch (Exception ex) { System.Windows.MessageBox.Show(ex.Message); } }