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

Set focus on Tabpage when menu item is clicked.

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


Joined: 03 Oct 2005
Posts: 57
Location: Rotterdam - Netherlands

PostPosted: Mon Oct 24, 2005 8:59 pm    Post subject: Set focus on Tabpage when menu item is clicked. Reply with quote

Guys,

Is it possible to set the focus on a tab page when a menu item is clicked?

Like this:
- Form including several tab pages.
- Menu including several menu items.
- Click on a menu item and for example the second tab page gets the focus and will show just like when you click on the tab page itself.

Building a small app in KF.NET and would like the "about button" in the "about menu" to display the "about tab page". Just to avoid having to create a second form that opens when the "about menu item" is clicked.

_________________
Mart

- He's chained forever to a world that's departed.....It's not enough, it's not enough - Sorrow by Pink Floyd.
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Tue Oct 25, 2005 2:15 am    Post subject: Reply with quote

The next release of Kixforms.Net has some enhancements that make working with TabControls much easier. Please download the lastest version 3.1.21 and give the following script a try. It sets up some tab pages and menu items based on colors, you can select a tab page from the menu. There is prolly more than one way to skin this cat though. But this is a start...

Dont forget to dl and install the latest .net build.

Code:

Break On

$System = CreateObject("Kixforms.System")

$TabNames = "Red", "Blue", "Green", "Yellow", "Orange"

$Form = $System.Form()

$MainMenu = $System.MainMenu()
$FileMenu = $MainMenu.MenuItems.Add($System.MenuItem("File"))
$ExitMenu = $FileMenu.MenuItems.Add($System.MenuItem("Exit"))
$ExitMenu.Click = "$$Form.Close"

$TabMenu = $MainMenu.MenuItems.Add($System.MenuItem("Tabs"))

$Form.Menu = $MainMenu

$TabControl = $Form.Controls.Add($System.TabControl())
$TabControl.Dock = $System.DockStyle_Fill

; setup the tabs and tab menuitems ...

For Each $TabName In $TabNames
 $MenuItem = $TabMenu.MenuItems.Add($System.MenuItem($TabName))
 $MenuItem.Click = "MenuClick(" + $MenuItem.Text + ")"
 $TabPage = $TabControl.TabPages.Add($System.TabPage($TabName))
 $TabPage.BackColor = $System.Color.FromName($TabName)
Next

$Form.Center
$Form.Show

While $Form.Visible
 $= Execute($Form.DoEvents)
Loop

Exit 1

Function MenuClick($text)

 For Each $TabPage In $TabControl.TabPages
  If $TabPage.Text = $text
   $TabControl.SelectedTab = $TabPage
  Endif
 Next

EndFunction
Back to top
View user's profile Send private message
benny69
KiXforms Advocate
KiXforms Advocate


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

PostPosted: Tue Oct 25, 2005 2:32 am    Post subject: Reply with quote

here is a another example that includes the elusive toolbarbuttons:

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

$Form1 = $System.Form()
$Form1.Left = 0
$Form1.StartPosition = 0  ;FormStartPosition_Manual
$Form1.Size = $System.Size(608,434) ;(Width,Height)
$Form1.Text = "Select TabPages"
$Form1.Top = 0

$Panel1 = $System.Panel()
$Panel1.Dock = 5  ;Fill
$nul = $Form1.Controls.Add($Panel1)

$Toolbar1 = $System.Toolbar()
$Toolbar1.Appearance = $System.ToolBarAppearance_Flat
$Toolbar1.ButtonSize = $System.Size(57,36) ;(Width,Height)
$Toolbar1.ButtonClick = "ToolBarButtonSelectTabPage($$Toolbar1.ButtonClickEventArgs.Button)"
$nul = $Form1.Controls.Add($Toolbar1)

$ToolBarButtonTabPage1 = $Toolbar1.Buttons.Add($System.ToolBarButton("TabPage1"))
$ToolBarButtonTabPage1.ParitalPush = 0  ;False
$ToolBarButtonTabPage1.Pushed = 0  ;False
$ToolBarButtonTabPage1.Style = 1  ;PushButton

$ToolBarButtonTabPage2 = $Toolbar1.Buttons.Add($System.ToolBarButton("TabPage2"))
$ToolBarButtonTabPage2.ParitalPush = 0  ;False
$ToolBarButtonTabPage2.Pushed = 0  ;False
$ToolBarButtonTabPage2.Style = 1  ;PushButton

$ToolBarButtonTabPage3 = $Toolbar1.Buttons.Add($System.ToolBarButton("TabPage3"))
$ToolBarButtonTabPage3.ParitalPush = 0  ;False
$ToolBarButtonTabPage3.Pushed = 0  ;False
$ToolBarButtonTabPage3.Style = 1  ;PushButton


$MainMenu1 = $System.MainMenu()

$File = $MainMenu1.MenuItems.Add($System.MenuItem("File"))

$Exit = $File.MenuItems.Add($System.MenuItem("Exit"))
$Exit.Click = "ExitForm()"

$TabPages = $MainMenu1.MenuItems.Add($System.MenuItem("TabPages"))

$TabPage1Menu = $TabPages.MenuItems.Add($System.MenuItem("TabPage1"))
$TabPage1Menu.Click = "MenuSelectTabPage('1')"

$TabPage2Menu = $TabPages.MenuItems.Add($System.MenuItem("TabPage2"))
$TabPage2Menu.Click = "MenuSelectTabPage('2')"

$TabPage3Menu = $TabPages.MenuItems.Add($System.MenuItem("TabPage3"))
$TabPage3Menu.Click = "MenuSelectTabPage('3')"

$Form1.Menu = $MainMenu1

$Statusbar1 = $System.Statusbar()
$Statusbar1.Text = "Statusbar1"
$nul = $Form1.Controls.Add($Statusbar1)

$TabControl1 = $System.TabControl()
$TabControl1.Dock = 5  ;Fill
$nul = $Panel1.Controls.Add($TabControl1)

$TabControl1TabPage1 = $System.TabPage()
$TabControl1TabPage1.Text = "TabPage1"
$nul = $TabControl1.Controls.Add($TabControl1TabPage1)

$TabControl1TabPage2 = $System.TabPage()
$TabControl1TabPage2.Text = "TabPage2"
$nul = $TabControl1.Controls.Add($TabControl1TabPage2)

$TabControl1TabPage3 = $System.TabPage()
$TabControl1TabPage3.Text = "TabPage3"
$nul = $TabControl1.Controls.Add($TabControl1TabPage3)

$Form1.Show  ;Displays the Form



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

Function MenuSelectTabPage($Page)
   
   Select
      Case $Page = 1
         $TabControl1.SelectedIndex = 0
      Case $Page = 2
         $TabControl1.SelectedIndex = 1
      Case $Page = 3
         $TabControl1.SelectedIndex = 2
   EndSelect
   
EndFunction

Function ToolBarButtonSelectTabPage($ToolBarButtonClicked)
   
   Select
      Case $ToolBarButtonClicked.Text = "TabPage1"
         $TabControl1.SelectedIndex = 0
      Case $ToolBarButtonClicked.Text = "TabPage2"
         $TabControl1.SelectedIndex = 1
      Case $ToolBarButtonClicked.Text = "TabPage3"
         $TabControl1.SelectedIndex = 2
   EndSelect
   
EndFunction

Function ExitForm()
   $Form1.Close
EndFunction

_________________
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
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Tue Oct 25, 2005 2:36 am    Post subject: Reply with quote

Even though Benny's example doesnt have color ;0) I think his is better, its a more "practical" way of doing this - easier to understand I think.
Back to top
View user's profile Send private message
benny69
KiXforms Advocate
KiXforms Advocate


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

PostPosted: Tue Oct 25, 2005 2:42 am    Post subject: Reply with quote

I think that Shawn's is much nicer, because it is far more condenced, he's good at that stuff.
_________________
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
Mart
KiXforms Regular
KiXforms Regular


Joined: 03 Oct 2005
Posts: 57
Location: Rotterdam - Netherlands

PostPosted: Tue Oct 25, 2005 10:32 am    Post subject: Reply with quote

LOL
Get a room you guys Razz Wink

Both worked great. Thanx.

_________________
Mart

- He's chained forever to a world that's departed.....It's not enough, it's not enough - Sorrow by Pink Floyd.
Back to top
View user's profile Send private message
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