Answer the question
In order to leave comments, you need to log in
How to draw in visual studio c++ 2010?
Hello. Can you please tell me how to draw a line on a PictureBox in visual studio? I did it like this, no errors, but nothing happens ...
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
pictureBox1->Refresh();
}
private: System::Void pictureBox1_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) {
// Create pen.
Pen^ blackPen = gcnew Pen( Color::Black,3.0f );
// Create location and size of ellipse.
int x = 0;
int y = 0;
int width = 100;
int height = 100;
// Draw ellipse to screen.
e->Graphics->DrawEllipse( blackPen, x, y, width, height );
}
Answer the question
In order to leave comments, you need to log in
Why are you drawing in pictureBox ? isn't pictureBox for placing a picture?
Try using flowLayoutPanel.
For example:
SolidBrush^ myBrush = gcnew SolidBrush(Color::White);
Graphics^ gr= this->flowLayoutPanel1->CreateGraphics(); // try this with pictureBox
gr->FillRectangle(myBrush, 0, 0, 100, 100);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question