Type Casting??

Hi, i am trying to write a small app using vc++ express and the mysql api. i can connec to a db, retrieve results but i want to add these to an listbox. using listBox1->Items->Add(rowIdea);

but this gives the error:

'System::Windows::Forms::ListBox::ObjectCollection::Add' : cannot convert parameter 1 from 'char *' to 'System::Object ^'

so i need a way to type cast this i presume or a way around it at least. n e suggestions would be great. thanks



Answer this question

Type Casting??

  • dkorsunsky

    Thank you :)

    worked like a charm


  • alex2308

    Convert the char* to a System::String. Use the String constructor that takes a char* to do this.

    Items->Add(gcnew String(pChar));



  • Type Casting??