Page 2 of 2

Re: Gridview borders

Posted: Wednesday 11th December 2019 6:01am
by stevedee
Technopeasant wrote: Wednesday 11th December 2019 2:12am I wanted to be able to change the colour and size of the borders of my controls, but I might just have to add my own drawing code.
Yes I think that is the only option. My example just used a panel control slightly larger than the main control.

For anyone interested, here is my demo code using a TextArea and a Panel:-
Public Sub SetBorder(iSize As Integer, iColour As Integer)

  TextArea1.Border = False
  With Panel1
    .NoTabFocus = True
    .Left = TextArea1.Left - iSize
    .Top = TextArea1.Top - iSize
    .Width = TextArea1.Width + iSize * 2
    .Height = TextArea1.Height + iSize * 2
    .Background = iColour
  End With
  
End
...and also a 1 second Timer to run it:-
Public Sub Timer1_Timer()
Dim iBorder As Integer
Dim iColour As Integer

  iBorder = Rnd(0, 50)
  iColour = Rnd(0, 16700000)
  SetBorder(iBorder, iColour)
  TextArea1.Text = " Border size: " & iBorder

End

Re: Gridview borders

Posted: Wednesday 11th December 2019 2:47pm
by cogier
I have had a look at this and I think the property to use is 'Padding'

Have a look at the attached (4 lines of code)

Image
Test1.tar.gz
(12.47 KiB) Downloaded 450 times

Re: Gridview borders

Posted: Saturday 14th December 2019 4:53am
by Technopeasant
Might work for a panel, but does not seem to do what I want for picture boxes.

While it is disappointing that everything I read about how QT style sheets work suggests this should be possible, I have just implemented my own paint commands, which gave me the option of drawing ellipse borders as well.

Re: Gridview borders

Posted: Saturday 14th December 2019 10:35am
by cogier
Might work for a panel, but does not seem to do what I want for picture boxes.
See attached, same as before but with a PictureBox. If this is not what you are looking for please elaborate.

Image
Test1.tar.gz
(34.12 KiB) Downloaded 453 times

Re: Gridview borders

Posted: Monday 23rd December 2019 12:25am
by Technopeasant
Does the job for UI elements I guess, but my drawing commands are working out better for dynamic game elements. Thanks for the tips though.