Dim cv as Canvas
cv.Initialize(calPanels(pnlNumber))
cv.DrawColor(Colors.Red) 'Background
Dim dstRect as Rect
dstRect.Initialize(0,0,calPanels(pnlNumber).Width, calPanels(pnlNumber).Height))
cv.DrawRect(dstRect, Colors.Green, False, 4dip) 'Border color and width
Dim cv as Canvas
cv.Initialize(calPanels(pnlNumber))
cv.DrawColor(Colors.Red) 'Background
Dim dstRect as Rect
dstRect.Initialize(0,0,calPanels(pnlNumber).Width, calPanels(pnlNumber).Height))
cv.DrawRect(dstRect, Colors.Green, False, 4dip) 'Border color and width
There is nothing wrong with the code. It changes background colour and the border colour. If you want to only change the border colour, have the first parameter to Initialize2 set to the same colour as your panel background (you know what the colour of your background is), and only change the fourth parameter which is the colour of the border. You can set the border width and border corner radius as well.
Why would you want to draw a rectangle on top of the panel, if it is easier to do this way?