Jeevan B

Jeevan B

  • NA
  • 1
  • 1.5k

read .resx file and display the contents in datagridview

Oct 8 2014 10:00 AM
I have created an application where I have to load the .resx file and display the contents of the .resx file in the datagridview. I am loading the .resx through menustrip. I have tried using the following code, but no data show up in the datagridview
 
private void openToolStripMenuItem_Click(object sender, EventArgs e)
 { 
OpenDialog.Reset();
 OpenDialog.InitialDirectory = Directory.GetCurrentDirectory();
 OpenDialog.RestoreDirectory = false; 
OpenDialog.Filter = "Resource files (*.resx)|*.resx"; i
f (OpenDialog.ShowDialog() == DialogResult.OK) 
{ 
StreamReader MyStream = new StreamReader(OpenDialog.FileName); 
BBookGrid.DataSource = null;         
m_BBookTable.Clear(); //Clear the existing table 
BBookGrid.DataSource = m_BBookTable; 
try 
{ 
while (true) 
{ 
String MyLine = MyStream.ReadLine();
 if (MyLine == null) 
{ 
break; 
} 
else if (MyLine.Length != 0) 
{ String[] fields = MyLine.Split(Separator.ToCharArray()); 
if (fields.GetLength(0) == NumColumns) 
{                         
m_BBookTable.Rows.Add(m_BBookTable.NewRow());
m_BBookTable.Rows[m_BBookTable.Rows.Count - 1][SourceCol] = fields[0].Trim();  
 m_BBookTable.Rows[m_BBookTable.Rows.Count - 1][TargetCol] = fields[1].Trim(); } } } } 
catch (Exception ex) 
{ MessageBox.Show("Fatal Error" + ex.ToString()); 
Application.Exit(); } } }