Gridview borders

Post your Gambas programming questions here.
User avatar
stevedee
Posts: 518
Joined: Monday 20th March 2017 6:06pm

Re: Gridview borders

Post 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
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Gridview borders

Post 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 445 times
User avatar
Technopeasant
Posts: 140
Joined: Saturday 13th July 2019 6:50pm
Location: Stony Plain, Alberta, Canada
Contact:

Re: Gridview borders

Post 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.
Technical director,
Piga Software
http://icculus.org/piga/
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Gridview borders

Post 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 446 times
User avatar
Technopeasant
Posts: 140
Joined: Saturday 13th July 2019 6:50pm
Location: Stony Plain, Alberta, Canada
Contact:

Re: Gridview borders

Post 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.
Technical director,
Piga Software
http://icculus.org/piga/
Post Reply