I am a newbie in Visual Studio (C#). I want to store a text read from a text file and display it on a TextBlock control, but just for a specified row. How can I do that?
I've try to search on the internet, and most of them just show the way to read and write.
I have one TextBlock (named 'FlashText'), and two Button (one for the 'Previous' button, another one is for the 'Next' button). What I want is, when I hit the 'Next' button, then the TextBlock showing a text read from a txt file on a specified row (for instance, the first row). And when I hit the 'Next' again, then the TextBlock should be show the second row text read from the file.
The purpose is to make a simple flash card. The code is here:
private void btnRight_Click(object sender, RoutedEventArgs e) {
string filePath = @"D:\My Workspaces\Windows Phone 7 Solution\SimpleFlashCard\EnglishFlashCard.txt";
int counter = 0;
string line;
System.IO.StreamReader file = new System.IO.StreamReader(filePath);
while((line = file.ReadLine()) != null) {
Console.WriteLine(line);
counter++;
}
}
file.Close();
FlashText.Text = Console.ReadLine();
Please help. Thanks a bunch.