How do I populate a DataGridView with arrays containing strings? (I get convertion error C2664)
- From: "Fleemox" <garanteratspam@xxxxxxxx>
- Date: 17 Feb 2007 14:56:55 -0800
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::DataGridViewRowCollection::Add(...cli::array<Type,dimension>
^)' : 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 but 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
ready created inside quotemarks).
What is the solution for this? 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, not by refactoring the whole
code.
http://msdn2.microsoft.com/en-us/library/system.windows.forms.datagridview.columns.aspx
http://support.microsoft.com/kb/816146
.
- Follow-Ups:
- Re: How do I populate a DataGridView with arrays containing strings? (I get convertion error C2664)
- From: David Ching
- Re: How do I populate a DataGridView with arrays containing strings? (I get convertion error C2664)
- From: Joseph M . Newcomer
- Re: How do I populate a DataGridView with arrays containing strings? (I get convertion error C2664)
- From: Ajay Kalra
- Re: How do I populate a DataGridView with arrays containing strings? (I get convertion error C2664)
- Prev by Date: Re: 'ENTER' key problem in edit box
- Next by Date: Re: Debug assertion failed (in afxwin1.inl) line 21
- Previous by thread: Debug assertion failed (in afxwin1.inl) line 21
- Next by thread: Re: How do I populate a DataGridView with arrays containing strings? (I get convertion error C2664)
- Index(es):
Relevant Pages
|
Loading