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.
UPDATE:
Recently the main code is:
public partial class MainPage : PhoneApplicationPage
{
private FlashCard _flashCard;
// Constructor
public MainPage()
{
InitializeComponent();
// This could go under somewhere like a load new flash card button or
// menu option etc.
try
{
_flashCard = new FlashCard(@"D:\My Workspaces\Windows Phone 7 Solution\FCard\MyDocuments\EnglishFlashCard.txt");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void btnLeft_Click(object sender, RoutedEventArgs e)
{
DisplayPrevious();
}
private void btnRight_Click(object