Is there a more efficient way to set properties of each tab in a tabstrip?

Post your Gambas programming questions here.
User avatar
BruceSteers
Posts: 1877
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Is there a more efficient way to set properties of each tab in a tabstrip?

Post by BruceSteers »

AndrewZabar wrote: Sunday 12th May 2024 1:27pm Really simple, to be honest.

Code: Select all

Public Sub Form_Open()

  TabPanel1.Count = 3

End
Maybe I need to wait until the control is created? Where then would I put this code? This same code in the Form_Open() sub works perfectly with a tabStrip, just not a tabPanel.
Andrew Post your code !.

I tried this...

Code: Select all

Public Sub Form_Open()

  TabPanel1.Count = 3
  Print TabPanel1.Count

End
It says 3

you posted your example saying "Really simple, to be honest. "

But if that's all the code there is how do you know if you have 3 tabs or not?
So what do you try to do after that does not work for you or makes you think it's not working?
If at first you don't succeed , try doing something differently.
BruceS
User avatar
thatbruce
Posts: 237
Joined: Saturday 4th September 2021 11:29pm

Re: Is there a more efficient way to set properties of each tab in a tabstrip?

Post by thatbruce »

They are there, they just dont have titles.
User avatar
thatbruce
Posts: 237
Joined: Saturday 4th September 2021 11:29pm

Re: Is there a more efficient way to set properties of each tab in a tabstrip?

Post by thatbruce »

Which in a way actually does characterize this as a bug in the sense of "UI" (which btw is a pseudo-science that I have a great deal of loathing for.)
I have recently (today) been discussing a variant of this on another site.
The user has an expectation that an action results in a visual change and that change should be "expected". Consider this theoretical. There is a tabpanel and a button that (for who knows what reason) that lets the user add another tab. At the moment there will be no visual indication that the new panel exists. What is the users natural reaction? Click it again and again and again ... until such time that they raise a bug.
To my way of thinking this is either a poor piece of design or a bad implementation. So now I tend to agree with Andrew. Someone should do something about this! :?
b
User avatar
BruceSteers
Posts: 1877
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Is there a more efficient way to set properties of each tab in a tabstrip?

Post by BruceSteers »

thatbruce wrote: Monday 13th May 2024 12:55pm To my way of thinking this is either a poor piece of design or a bad implementation. So now I tend to agree with Andrew. Someone should do something about this! :?
b
Bagsy not me! i'm pestering Ben about enough bugs at present ;)
(and i just moaned at him for dismissing a problem because it didn't exist on his KDE/Manjaro! so i'm on tender ground as it is ;) )


My way of thinking is it's just insufficient coding. (no offense intended) but of course you would give the tabs unique titles.

Implementation is not a simple as you'd think, if you create and remove tabs then you cannot trust the numbering, ie..
TabPanel1.Count=3 ' Creates Tab 1, Tab 2, Tab 3
Then TabPanel1[1].Delete ' Deletes Tab 2 leaving Tab 1, Tab 3
Then TabPanel1.Count=3 ' would create Tab 3 but Tab 3 already exists. should it renumber them all? or call the new one Tab 2 or Tab 4?

I think It's better left to the programmer to choose.
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1877
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: Is there a more efficient way to set properties of each tab in a tabstrip?

Post by BruceSteers »

But then after saying all that....

You could just do this......

Here is a simple TabPanel upgrade that if you save this code as a file called TabPanel.class in your project .src folder it will add a "AutoTitle" property to TabPanel.

attached is a project that shows it at work.

It's really not much code to make a TabPanel auto-title itself :)

' Gambas class file
' Name: TabPanel.class

Export
Public Const _Properties As String = "*,AutoTitle"
'' Automatically title tabs in numerical order
Property AutoTitle As Boolean Use $bAutoTitle

Public Sub Panel_Arrange()
  
  If $bAutoTitle Then 
    For c As Integer = 1 To Me.Count
      Me[c - 1].Text = "Tab " & c
    Next
  Endif
  Super.Panel_Arrange
  
End
Attachments
TabPanel-AutoTitle-0.0.tar.gz
(53.18 KiB) Downloaded 246 times
If at first you don't succeed , try doing something differently.
BruceS
Post Reply