Reputation: 1594
I'm trying to print a datagridview by drawing to bitmap using visual studio 2008 C++ Windows Forms Application, however I'm having trouble converting the 2 types mentioned in the title. This is the method being called:
private:
void printDocument1_PrintPage(System::Object ^ sender,
System::Drawing::Printing::PrintPageEventArgs ^ e)
{
Bitmap^ bm = gcnew Bitmap(this->dataGridView1->Width, this->dataGridView1->Height);
this->dataGridView1->DrawToBitmap(bm, new Rectangle(0, 0, this->dataGridView1->Width, this->dataGridView1->Height));
e->Graphics->DrawImage(bm, 0, 0);
}
System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
printDialog1->ShowDialog();
printDocument1->Print();
}
However upon compiling the code I'm getting this error:
error C2664: 'System::Windows::Forms::Control::DrawToBitmap' : cannot convert parameter 2 from 'System::Drawing::Rectangle *' to 'System::Drawing::Rectangle'
I'm clueless. How can I fix this error?
Upvotes: 0
Views: 959
Reputation: 488
Shouldn't the new Rectangle(...)
code be gcnew Rectangle(...)
? Remember that in Managed C++, new
is NOT the same as gcnew
.
Upvotes: 2