hi
excuse me (i can,t speak en good)
---------------------------------
my project have 15 text file (A.txt, B.txt & ...)
and have a listbox with items(A, B, & ...)
i want ...
when click in a item (A) from listbox ... open file (A.txt) in richtextbox !
how to do it ?
plz help ...
tanks
Loading

Hemant SrivastavaPosted Jul 28, 2014, 1:57 PM
//Directory where all the data files are kept
string sDirectory = @"D:\CSharpProject\MyData\";
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
string sFilePath = sDirectory + listBox1.SelectedItem.ToString().Trim() + ".txt";
LoadMyFile(sFilePath);
}
public void LoadMyFile(string filename)
{
if (File.Exists(filename))
{
// Load the contents of the file into the RichTextBox.
richTextBox1.LoadFile(filename, RichTextBoxStreamType.PlainText);
}
else
{
MessageBox.Show("File doesn't exist in the folder : " + sDirectory );
}
}
Satyapriya NayakPosted Jul 28, 2014, 11:35 AM