Simple code in C++ Builder XE8

86 Views Asked by At

I want that code for C++ Builder XE8

private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
    var str = listBox1.SelectedItem.ToString();
    if (str == "A")
    {
        textBox1.Text = "You have selected A";
    }

    else if (str == "B")
    {
        textBox1.Text = "You have selected B";
    }
    else
    {
        textBox1.Text = "You have not selected A or B";
    }
}
1

There are 1 best solutions below

0
On

Perhaps the following C++ Builder could be like this:

private:
void listBox1_SelectedIndexChanged(void *sender, EventArgs *e)
{
    auto str = listBox1::SelectedItem->ToString();
    if (str == "A")
    {
        textBox1->Text = "You have selected A";
    }

    else if (str == "B")
    {
        textBox1->Text = "You have selected B";
    }
    else
    {
        textBox1->Text = "You have not selected A or B";
    }
}