I need to display the stack list on a listbox, when i push a button (push) the data will add to stack and display each on the listbox and every time user enter data(names, etc) its keep on adding to the stack and display on the list box..
Any help with an example will be helpful....
regards
Mavic
private void button1_Click(object sender, EventArgs e)
{
int result;
result = stack.push(txtLastName.Text + txtPayRate.Text);
if (result == 1)
{
MessageBox.Show("Employee Lastname: " + txtLastName.Text + "\n Employee Payrate: " + txtPayRate.Text + "");
}
else
MessageBox.Show("You can't add an empty value");
txtLastName.Clear();
txtPayRate.Clear();
}
private void button2_Click(object sender, EventArgs e)
{
string top;
top = stack.top();
if (top != null)
{
MessageBox.Show("The Employee on top is: " + top);
}
else
MessageBox.Show("Your stack is empty");
}
private void button3_Click(object sender, EventArgs e)
{
string pop;
pop = stack.pop();
if (pop != null)
{
MessageBox.Show("Employee is dismissed: " + pop);
lstStack.Items.Clear();
}
else
MessageBox.Show("Your stack is empty");
}
private void button4_Click(object sender, EventArgs e)
{
lstStack.Items.Add(txtLastName.Text);
lstStack.Items.Add(txtPayRate.Text);
}
}