none
value from listbox - simple error RRS feed

  • Question

  • Hi,

     

    I'm new to C++. I have probably made a very simple error.

     

    Please tell me what is wrong with the following. I am only trying to get the text value from a selection made from the listbox.

     

    private: System::Void listBox1_SelectedIndexChanged(System:: Object^ sender, System::EventArgs^ e) {

    //////////// The error will be on the following line

    this->textBox10->Text= (listBox1->SelectedItem());

    }

     

    I get the following error:-

    error C2064: term does not evaluate to a function taking 0 arguments

     

    Thank you,

     

    paul

    Wednesday, November 14, 2007 7:56 PM

Answers

  •  Paulothisland wrote:

    private: System::Void listBox1_SelectedIndexChanged(System:: Object^ sender, System::EventArgs^ e) {

    //////////// The error will be on the following line

    this->textBox10->Text= (listBox1->SelectedItem());

    }

     

    I get the following error:-

    error C2064: term does not evaluate to a function taking 0 arguments

    Hi Paul,

     

    SelectedItem is a property of listbox, it is not a member function, so use following code to solve the problem:

    Code Block

    this->textBox10->Text = this->listBox1->SelectedItem->ToString();

     

    regards,

    rico

    Tuesday, November 20, 2007 5:19 AM
    Moderator

All replies

  • Any feedback would really help this C++ beginner.

     

    Thanks,

     

    Paul

     

    Wednesday, November 14, 2007 11:24 PM
  • Don't expect an answer in less than 4 hours.

    Thursday, November 15, 2007 4:45 AM
  •  Paulothisland wrote:

    private: System::Void listBox1_SelectedIndexChanged(System:: Object^ sender, System::EventArgs^ e) {

    //////////// The error will be on the following line

    this->textBox10->Text= (listBox1->SelectedItem());

    }

     

    I get the following error:-

    error C2064: term does not evaluate to a function taking 0 arguments

    Hi Paul,

     

    SelectedItem is a property of listbox, it is not a member function, so use following code to solve the problem:

    Code Block

    this->textBox10->Text = this->listBox1->SelectedItem->ToString();

     

    regards,

    rico

    Tuesday, November 20, 2007 5:19 AM
    Moderator