Hi all,

I am new to this group so I need your help. I'm working on my application to make the border for the panel.

When I try this:

Code:
    int thickness = 3;
    Pen pen(Color::DarkGray, thickness);
    Rectangle r = Rectangle(0, 0, panel2->ClientRectangle.Width, panel2->ClientRectangle.Height);
    e->Graphics->DrawRectangle(pen, r);

I'm getting the error:

Code:
    'void System::Drawing::Graphics::DrawRectangle(System::Drawing::Pen ^,System::Drawing::Rectangle)' : cannot convert parameter 1 from 'System::Drawing::Pen' to 'System::Drawing::Pen ^'


The error are jumping on this line:

Code:
    e->Graphics->DrawRectangle(pen, r);


Here is the full code:

Code:
   private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
	    panel2->BorderStyle = BorderStyle::None;
    }

    private: System::Void panel2_Paint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) {
	    int thickness = 3;
			 

		Pen pen(Color::DarkGray, thickness);
		Rectangle r = Rectangle(0, 0, panel2->ClientRectangle.Width, panel2->ClientRectangle.Height);
		e->Graphics->DrawRectangle(pen, r);

	}

I dont really understand why i am getting an error when I am trying to set the blue line border with a pen.

Can you please show me an example what is the correct way to display the blue border for the panel??

Thanks,
Mark