Change text color of a listbox item

  1. Change DrawMode = OwnerDrawFixed

private void listBox1_DrawItem(object sender, DrawItemEventArgs e) {

e.DrawBackground();

e.Graphics.DrawString(listBox1.Items[e.Index].ToString(), listBox1.Font, Brushes.Green, e.Bounds);

}

Anuncios

After select TreeView

if(e.Node.Name.EndsWith(“pdf”))

Process.Start(e.Node.Name);

else if(e.Node.Name.EndsWith(“txt”)){

this.richTextBox1.Clear();

StreamReader reader = new StreamReader(e.Node.Name);

this.richTextBox1.Text = reader.ReadToEnd();

reader.Close();

}

OR

if(e.Node.Text.Contains(“.”))

Process.Start(e.Node.Name);

 

*e.Node.Text = filename + extension

e.Node.Name = full path