mohit singh

mohit singh

  • NA
  • 64
  • 1.9k

Extract similar data from text file as input in the textbox

Apr 17 2020 3:21 AM
I want to extract the input data in text box from text file and want to display the result in datagrid.
i am using textbox for userentry, a button for loading the requirement and datagrid to fill the requirement and display ...
  1. private void Button_Click(object sender, RoutedEventArgs e)  
  2. {  
  3. {  
  4. string var;  
  5. var = tb.Text;  
  6. var queryname = new List();  
  7. using (StreamReader reader = new StreamReader("C:\\Documents\\TestFile.txt"))  
  8. {  
  9. while (true)  
  10. {  
  11. string line = reader.ReadLine();  
  12. if (line == null)  
  13. {  
  14. break;  
  15. }  
  16. queryname.Add(new QueryName(line));  
  17. }  
  18. }  
  19. //var grid = sender as DataGrid;  
  20. dg.ItemsSource = queryname;  
  21. } 

Answers (2)