Forum > Coding >

How do i make listbox selected item to show file text in textbox?

Posts: 3

Threads: 2

Joined: Oct, 2018

Reputation: 0

Posted

How do i make listBox1.SelectedItem text file text to show in my richtextbox???
any help please?

  • 0

Posts: 4

Threads: 3

Joined: Aug, 2018

Reputation: 0

Replied

Easy

 private void Form1_Load(object sender, EventArgs e)
 Â Ã‚ Ã‚ Ã‚ Ã‚ Ã‚  {
 Â Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚  if (!Directory.Exists("Scripts"))
 Â Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚  Directory.CreateDirectory("Scripts");
 Â Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚  foreach (string file in Directory.GetFiles("Scripts"))
 Â Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚  this.listBox1.Items.Add((object)Path.GetFileName(file));
 Â Ã‚ Ã‚ Ã‚ Ã‚ Ã‚  }
 Â Ã‚ Ã‚ Ã‚ Ã‚ Ã‚  private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
 Â Ã‚ Ã‚ Ã‚ Ã‚ Ã‚  {
 Â Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚  if (this.listBox1.SelectedItem == null)
 Â Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚  return;
 Â Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚  this.ScriptBox.Text = File.ReadAllText("Scripts\\" + this.listBox1.SelectedItem.ToString());
 Â Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚ Ã‚  this.ScriptBox.Refresh();
 Â Ã‚ Ã‚ Ã‚ Ã‚ Ã‚  }

there you go

  • 0

Posts: 2

Threads: 1

Joined: Nov, 2018

Reputation: 0

Replied

Easy , ;) 

Here ... 


Use this . 


private void listBox1_SelectedIndexChanged_1(object sender, EventArgs e) => fastColoredTextBox1.Text = File.ReadAllText($"./Scripts/{listBox1.SelectedItem}");

then inside the exploit folder make a folder called Scripts... 

then make a button and make the code this :
listBox1.Items.Clear();//Clear Items in the LuaScriptList
            Functions.PopulateListBox(listBox1, "./Scripts", "*.txt");
            Functions.PopulateListBox(listBox1, "./Scripts", "*.lua");

then go into functions and paste this : 
public static void PopulateListBox(ListBox lsb, string Folder, string FileType)
        {
            DirectoryInfo dinfo = new DirectoryInfo(Folder);
            FileInfo[] Files = dinfo.GetFiles(FileType);
            foreach (FileInfo file in Files)
            {
                lsb.Items.Add(file.Name);
            }
        }


I love to help out .... So if this did let me know ;) 

  • 0

Users viewing this thread:

( Members: 0, Guests: 1, Total: 1 )