Beginner to C#. I am trying to create a simple program that will populate text in a textbox based on the listbox entry that is selected once the button is pressed. I am trying different things but can't seem to find a way to get the text to populate in the text box. Code below. Thanks in advance.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
List<string> RadioList = new List<string>();
RadioList.Add("Test1");
RadioList.Add("Test2");
RadioList.Add("Test3");
listBox1.DataSource = RadioList;
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void RPODecoderButton_Click(object sender, EventArgs e)
{
if (listBox1.SelectedItem == "Test1")
{
RPOTextBox.Text = string.Empty;
RPOTextBox.AppendText("Hello");
}
else if (listBox1.SelectedItem == "Test2")
{
RPOTextBox.Text = string.Empty;
RPOTextBox.AppendText("Hi");
}
}