Greetings,
I am stuck at this project quite a bit now, was wondering if anyone here can help me out :)
The scenario of this project is "User gives some value as input by textbox and they'll be added to first listbox "Vertically" by clicking the first button, and after that by clicking second button all of the data will be shown reversely on second listbox"
here is my code so far:
private void button1_Click(object sender, EventArgs e)
{
string[] n = new string[listBox1.Items.Add(textBox1.Text)];
for ( int i = 0; i < n.Length; i++)
{
n[i] = listBox1.Items[i].ToString();
}
}
private void button2_Click(object sender, EventArgs e)
{
string n = n.Reverse<>;
for(int i = 0; i < n.Length; i++)
{
listBox2.Items[i].ToString();
}
listBox1.Items.Clear();
}
----------
First button works perfectly however the reversing the array and show it in listbox2 is somehow not working,
Thanks in advance.
Loading

Dipankar BiswasRank #992 · 2K reputationPosted May 13, 2015, 8:11 PM EDT
Check this video. Work with Arrays and listbox.https://www.youtube.com/watch?v=5VUyvCfFvn4
Nanhe SiddiqueRank #1,103 · 1.7K reputationPosted May 13, 2015, 8:49 PM EDT
for reverse you can write this
i think it may help you
Masoud A30 reputationPosted May 14, 2015, 12:34 PM EDT
Masoud A30 reputationPosted May 14, 2015, 12:35 PM EDT
Masoud A30 reputationPosted May 14, 2015, 1:56 PM EDT
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public void button1_Click(object sender, EventArgs e)
{
string[] n = new string[listBox1.Items.Add(textBox1.Text)];
for (int x = 0 ; x < n.Length ; x++)
{
n[x] = listBox1.Items[x].ToString();
}
}
public void button2_Click(object sender, EventArgs e)
{
for (int i = listBox1.Items.Count - 1; i >= 0; i--)
{
listBox2.Items.Add(listBox1.Items[i]);
}
listBox1.Items.Clear();
}
}
}