My first C++ Form

  • Thread starter Thread starter Howard Kaikow
  • Start date Start date
H

Howard Kaikow

I'm trying to use a Form in C++ for the first time.
Alas, my only C++ .NET book is for 2002, so it does not cover Forms.

In the snippet below, where lstOutput is a Listbox control, I get the error:

i:\C++\C++Code\UseForm\Form1.h(121): error C2664:
'System::Windows::Forms::ListBox::ObjectCollection::Add' : cannot convert
parameter 1 from 'char *' to 'System::Object __gc *'

What do I have to do to correct the problem?

char *buffer;

buffer = "Bagels";
lstOutput->Items->Add(buffer);
lstOutput->Items->Add(S"and lox");
 
Howard Kaikow said:
I'm trying to use a Form in C++ for the first time.
Alas, my only C++ .NET book is for 2002, so it does not cover Forms.

In the snippet below, where lstOutput is a Listbox control, I get the
error:

i:\C++\C++Code\UseForm\Form1.h(121): error C2664:
'System::Windows::Forms::ListBox::ObjectCollection::Add' : cannot convert
parameter 1 from 'char *' to 'System::Object __gc *'

What do I have to do to correct the problem?

char *buffer;

buffer = "Bagels";
lstOutput->Items->Add(buffer);
lstOutput->Items->Add(S"and lox");

It compiles with:

lstOutput->Items->Add(new String("bagel"));

lstOutput->Items->Add(new String ("and lox"));


greets, Sebastian Dau
 
Sebastian Dau said:
It compiles with:

lstOutput->Items->Add(new String("bagel"));

lstOutput->Items->Add(new String ("and lox"));


Thanx.

So I can use

char *buffer;
buffer = "Bagels";
lstOutput->Items->Add(new String(buffer));
lstOutput->Items->Add(S"and lox");
 
Back
Top