Page 1 of 1

Listbox And Textbox

Posted: Tue Jan 11, 2011 12:55 pm
by upperdrag
hello people :)
Sorry to bother u all again however i need another help (yet again)

how do you make a listbox so that when you click on the selected index, the text will be loaded? and when you click on another index, another index,another text will be shown??
oh and also how can i read the textfile from a .txt? For example

----
Bears
------
Birds



I Click On Birds

All THe Information will be shown about bird, However i wanna to read the information through a txt file..? how is that possible??

Re: Listbox And Textbox

Posted: Tue Jan 11, 2011 1:02 pm
by mandai
This should work:
Code: Select all
    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        TextBox1.Text = ListBox1.Text
    End Sub
When you say read through do you mean read each line? You can use IO.File.ReadAllLines for that.

Re: Listbox And Textbox

Posted: Wed Jan 12, 2011 9:05 am
by upperdrag
im sorry but i know all of those however, how am i suppose to read it and save it with Commas for example













Bear
--------
Bird
--------


I Click On Bird, it reads from a textfile

and the textfile will be like






Birds Are Under Bird Category ,Bears Are Under Mammals Category


The Text will show "Birds Are Under Bird Category"


And The Listbox Reads From The Textfile too so it will be like

Birds,Bears