neue items in comboBox
-
ich möchte aus einer datei einzelne strings aus einer datei auslesen und diese dann zu einer comboBox zur Auswahl hinzufügen!!
ich mache das eben so:comboBox1->Items->Add (string1);
string1 ist eine Variable vom Typ string oder chararray!!
es kommt jedes mal folgender fehler:error C2664: 'System::Windows::Forms::ComboBox::ObjectCollection::Add' : cannot convert parameter 1 from 'char [8]' to 'System::Object ^'
oder
error C2275: 'std::string' : illegal use of this type as an expression
wenn ich einen string nehme!!
wie kann ich so ein System::Objekt erstellen???
wenn ich das mache gehts!!
comboBox1->Items->Add ("ka");
-
Die Add Methode erwartet einen System::String^.
std::string und char[] ist nicht ohne weiteres in ein System::String^ konvertierbar.char pch = "test"; comboBox1->Items->Add (gcnew String(pch)); // oder... std::string str = "test1"; comboBox1->Items->Add (gcnew String(str.c_str()));
-
danke