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
Masoud APosted May 14, 2015, 5:56 PM
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();
}
}
}
Masoud APosted May 14, 2015, 4:35 PM
Masoud APosted May 14, 2015, 4:34 PM
Nanhe SiddiquePosted May 14, 2015, 12:49 AM
for reverse you can write this
i think it may help you
Dipankar BiswasPosted May 14, 2015, 12:11 AM
Check this video. Work with Arrays and listbox.https://www.youtube.com/watch?v=5VUyvCfFvn4