F
Fleemox
This is my code (only the important parts of it):
int Rownumber = 1;
string Rowtext[8000];
DataGridView1->Rows->Add(Rowtext[Rownumber]);
This code (here simplyfied) should create a row in the grid and fill
the first cell with the text stored in the array Rowtext[1] but when
debugging I get the following error message:
error C2664: 'int
System::Windows::Forms:ataGridViewRowCollection::Add(...cli::array<Type,d
imension>
^)' : cannot convert parameter 1 from 'std::string' to
'System::Object^'
If I change the code to
DataGridView1->Rows->Add("dummytext");
it WILL put the dummytext into a cell.
It doesn't work if I first declare/assign a string like this:
string strDummy = "dummytext";
and then write
DataGridView1->Rows->Add(strDummy);
I guess the Add() function can't accept a string as the argument
(only
if the string is created in advance, inside quotemarks).
What is the solution for this problem? I have found a few links which
could
help me, but I'm a newbie and those solutions look too complicated
for
me. I just want to get rid of the error, but not by refactoring the
whole
code.
http://msdn2.microsoft.com/en-us/library/system.windows.forms.datagri...
http://support.microsoft.com/kb/816146
int Rownumber = 1;
string Rowtext[8000];
DataGridView1->Rows->Add(Rowtext[Rownumber]);
This code (here simplyfied) should create a row in the grid and fill
the first cell with the text stored in the array Rowtext[1] but when
debugging I get the following error message:
error C2664: 'int
System::Windows::Forms:ataGridViewRowCollection::Add(...cli::array<Type,d
imension>
^)' : cannot convert parameter 1 from 'std::string' to
'System::Object^'
If I change the code to
DataGridView1->Rows->Add("dummytext");
it WILL put the dummytext into a cell.
It doesn't work if I first declare/assign a string like this:
string strDummy = "dummytext";
and then write
DataGridView1->Rows->Add(strDummy);
I guess the Add() function can't accept a string as the argument
(only
if the string is created in advance, inside quotemarks).
What is the solution for this problem? I have found a few links which
could
help me, but I'm a newbie and those solutions look too complicated
for
me. I just want to get rid of the error, but not by refactoring the
whole
code.
http://msdn2.microsoft.com/en-us/library/system.windows.forms.datagri...
http://support.microsoft.com/kb/816146