KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

Dynamically added tabs

 
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion
View previous topic :: View next topic  
Author Message
Viggen
KiXforms Regular
KiXforms Regular


Joined: 28 Jun 2005
Posts: 40

PostPosted: Tue Dec 19, 2006 12:47 pm    Post subject: Dynamically added tabs Reply with quote

Hi!

Back again with another question, with an answer that probably is very obvious to everyone but me... Rolling Eyes

I'm fooling around with tabpages and I would like to add tabs from an array...

did some testing and I know I'm missing something simple Confused

Code:
Break On
$System = CreateObject("Kixforms.System")
If Not $System
   $nul= MessageBox("KiXforms.Net Not Initiated. This Script Will Now Close.","Error",16)
   Quit()
EndIf
$nul = $System.Application.EnableVisualStyles

$Form1 = $System.Form()
$Form1.Left = 0
$Form1.StartPosition = 0  ;FormStartPosition_Manual
$Form1.Size = $System.Size(758,659) ;(Width,Height)
$Form1.Text = "Form1"
$Form1.Top = 0

Tabs()
$Form1.Show  ;Displays the Form

While $Form1.Visible
   $Nul = Execute($Form1.DoEvents())
Loop
Exit 0


Function Tabs()
$nbr = 10

Dim $Tab[$nbr]

If Not(VarType($TabControl1) = 9)
$TabControl1 = $System.TabControl()
$TabControl1.Left = 5
$TabControl1.Top = 5
$TabControl1.Width = $Form.Width - 10
$TabControl1.Height = $Form.Height - 10
$nul = $Form1.Controls.Add($TabControl1)
Endif

For $i=1 to $nbr
  $Tab[$i] = $System.TabPage()
  $Tab[$i].Text = "TabPage " + $i
  $nul = $TabControl1.Controls.Add($Tab[$i])
  $i = $i + 1
Next
Endfunction


suggestions?

T.I.A

/Viggen
Back to top
View user's profile Send private message MSN Messenger
benny69
KiXforms Advocate
KiXforms Advocate


Joined: 30 Oct 2003
Posts: 567
Location: Lincoln, Ne

PostPosted: Tue Dec 19, 2006 1:17 pm    Post subject: Reply with quote

Hi Viggen,
Is this what you are looking for?
Code:

Dim $Tab[9]

Break On
$System = CreateObject("Kixforms.System")
If Not $System
   $nul= MessageBox("KiXforms.Net Not Initiated. This Script Will Now Close.","Error",16)
   Quit()
EndIf
$nul = $System.Application.EnableVisualStyles

$Form = $System.Form()
$Form.Left = 0
$Form.StartPosition = $System.FormStartPosition_Manual
$Form.Size = $System.Size(600,400) ;(Width,Height)
$Form.Text = "Form1"
$Form.Top = 0

$TabControl = $System.TabControl()
$TabControl.Left = 5
$TabControl.Top = 5
$TabControl.Width = $Form.ClientWidth - 10
$TabControl.Height = $Form.ClientHeight - 10
$nul = $Form.Controls.Add($TabControl)

For $Index = 0 to 9
   $Tab[$Index] = $System.TabPage()
   $Tab[$Index].Text = "TabPage"+$Index
   $nul = $TabControl.Controls.Add($Tab[$Index])
Next

$Form.Show  ;Displays the Form

While $Form.Visible
   $Nul = Execute($Form.DoEvents())
Loop
Exit 0

_________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)
Back to top
View user's profile Send private message Send e-mail
Viggen
KiXforms Regular
KiXforms Regular


Joined: 28 Jun 2005
Posts: 40

PostPosted: Tue Dec 19, 2006 1:37 pm    Post subject: Reply with quote

Hi!

Benny to the rescue, as always Smile

The result is what I'm looking for.

But again, I'm stumped as to what I missed. Laughing

/Viggen
Back to top
View user's profile Send private message MSN Messenger
benny69
KiXforms Advocate
KiXforms Advocate


Joined: 30 Oct 2003
Posts: 567
Location: Lincoln, Ne

PostPosted: Tue Dec 19, 2006 4:38 pm    Post subject: Reply with quote

Viggen,
The reason that you were not seeing the TabPages is these two lines:
Code:

$TabControl1.Width = $Form.Width - 10
$TabControl1.Height = $Form.Height - 10

You created the Form as '$Form1' not '$Form', so you were trying to pull the width of somthing that does not exist.
I aslo pulled what you were doing out of the function because there was no need for the function. I just created the 'TabControl' as any other control, then looped thru creation of the 10 'TabPages'.
I also changed the number of defined vars from 10 to 9, that is because an array is a zero based number and always starts with 0 (zero) so it should count from 0 to 9 for a total of 10.
I also changed this:
Code:

$TabControl.Width = $Form.Width - 10
$TabControl.Height = $Form.Height - 10

to this:
Code:

$TabControl.Width = $Form.ClientWidth - 10
$TabControl.Height = $Form.ClientHeight - 10

The .Width is the overall width of the form, where .ClientWidth is the inside (or the uasable area) of the form, where the controls are actually placed.

_________________
Wait don't order yet,... get KiXforms Designer .NET 2.0 (Beta)
KiXforms Designer .NET 2.0 (Beta)
Back to top
View user's profile Send private message Send e-mail
Viggen
KiXforms Regular
KiXforms Regular


Joined: 28 Jun 2005
Posts: 40

PostPosted: Wed Dec 20, 2006 6:47 am    Post subject: Reply with quote

Doooh!! Embarassed

I used the KF Designer to create the basic form, and missed the 1's totally, when I created the tabs manually... Rolling Eyes

Thanks for the tip on "ClientWidth" & "ClientHeight"!

/Viggen
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> KiXforms.NET Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group