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

TabPage Visible Property

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


Joined: 10 Aug 2005
Posts: 50

PostPosted: Sat Nov 12, 2005 11:59 pm    Post subject: TabPage Visible Property Reply with quote

Hi Shawn,

Is the "Visible" property implemented on TabPages yet?
I'm trying to hide/show TabPages depending on Group Membership.
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Sun Nov 13, 2005 4:37 am    Post subject: Reply with quote

There is no TabPage.Visible property. TabPage inherits from Control but .Net doesn't support it. If you search the web on strategies for working around this, there are a couple of options.

1) Build your TabPage on-the-fly, and dont include the pages that aren't supposed to be there.

2) Temporarily removing the TabPage from the TabPageCollection (TabPages property). With this strategy, the big question is - are you assigning all your TabPages to individual $variables, like this:

$TabPage1 = $TabControl.TabPages.Add(...

$TabPage2 = $TabControl.TabPages.Add(...

If you are, then Removing the TabPage may be a viable option ... here some code:

Code:

Break On

$System = CreateObject("Kixforms.System")

$Form = $System.Form()
$Form.ClientWidth = 400

$MainMenu = $System.MainMenu

$EditMenu = $MainMenu.MenuItems.Add($System.MenuItem("Edit"))

$HideMenu = $EditMenu.MenuItems.Add($System.MenuItem("Hide TabPage3"))
$HideMenu.Click = "HideClick()"

$ShowMenu = $EditMenu.MenuItems.Add($System.MenuItem("Show TabPage3"))
$ShowMenu.Click = "ShowClick()"

$Form.Menu = $MainMenu

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

$TabPage1 = $TabControl.TabPages.Add($System.TabPage("TabPage1"))
$TabPage2 = $TabControl.TabPages.Add($System.TabPage("TabPage2"))
$TabPage3 = $TabControl.TabPages.Add($System.TabPage("TabPage3"))
$TabPage4 = $TabControl.TabPages.Add($System.TabPage("TabPage4"))
$TabPage5 = $TabControl.TabPages.Add($System.TabPage("TabPage5"))

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

Exit 0

Function HideClick()

 If $TabControl.TabPages.IndexOf($TabPage3) <> -1

  $TabControl.TabPages.Remove($TabPage3)

 Endif

EndFunction

Function ShowClick()

 If $TabControl.TabPages.IndexOf($TabPage3) = -1

  $= $TabControl.TabPages.Add($TabPage3)

 Endif

EndFunction


The problem with this code is that the TabPages get added to the end of the TabControl, not inserted ... unfortunately, .Net has no TabPageCollection.Insert method :0(
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Sun Nov 13, 2005 4:49 am    Post subject: Reply with quote

The other option is ...

1) Build all your TabPages "outside" of the TabControl, like this:

$TabPage1 = $System.TabPage()
$TabPage1.Text = ..

$TabPage2 = $System.TabPage()
$TabPage2.Text = ..

Then, when you display information for a user, depending on group membership, you would clear the TabControl.TabPages collection and re-build (re-add) the various TabPages depending.
Back to top
View user's profile Send private message
mercury
KiXforms Regular
KiXforms Regular


Joined: 10 Aug 2005
Posts: 50

PostPosted: Sun Nov 13, 2005 12:52 pm    Post subject: Reply with quote

Thanks Shawn,

I think "build on the fly" will work best in my case.
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