Print Page | Close Window

[solved] TabControl - problem with closable Items

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Controls
Forum Description: Topics Related to Codejock Controls
URL: http://forum.codejock.com/forum_posts.asp?TID=18379
Printed Date: 07 May 2024 at 12:41pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: [solved] TabControl - problem with closable Items
Posted By: readypro
Subject: [solved] TabControl - problem with closable Items
Date Posted: 16 May 2011 at 9:20am
IDE : VB 6.0
Suite Control v.15.0.1

The NavigateButtonClick event of the TabControl control seems to return always 2 as the ID of the tab being closed

Sample code (put 1 commandbutton and 1 tabcontrol on a form)

Private Sub Command1_Click()
    Dim newTab As TabControlItem
    
    TabControl1.ShowCloseItemButton = xtpTabItemButtonAlways
    TabControl1.RemoveAll
    Set newTab = TabControl1.InsertItem(0, "1st tab", 0, 0)
    newTab.Closable = True
    Set newTab = TabControl1.InsertItem(0, "2nd tab", 0, 0)
    newTab.Closable = True
    Set newTab = TabControl1.InsertItem(0, "3rd tab", 0, 0)
    newTab.Closable = True
End Sub

Private Sub TabControl1_NavigateButtonClick(ByVal Id As Long, Cancel As Variant)
    MsgBox "Closing tab " & Id ' this displays always "2"
    Cancel = True
End Sub

On the manual i've read
Id : Id of the tab navigation button that was clicked.

It's a bug or it's normal?

Thanks





Replies:
Posted By: Oleg
Date Posted: 16 May 2011 at 12:46pm
Its id of navigation button. not Id of tab.

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: readypro
Date Posted: 18 May 2011 at 3:01am
Thanks Oleg,
actually i've set ShowCloseItemButton = xtpTabItemButtonSelected and i'm using SelectedItem to detect the clicked tab

Is it possible to retrieve also the clicked tab id using ShowCloseItemButton = xtpTabItemButtonAlways or another way to detect the tab that is being closed?



Posted By: younicke
Date Posted: 30 May 2011 at 1:36am
and also when u close an item using the closebutton... how do u get the actual itemcount of the tab?

Private Sub TabControl1_NavigateButtonClick(ByVal Id As Long, Cancel As Variant)
    MsgBox TabControl1.ItemCount
End Sub

this always return the actual itemcount (not deducting the tab that you closed).  does anybody know how to get the itemcount inside navigatebuttonclick event?


Posted By: sined
Date Posted: 06 October 2011 at 8:45am
Hello,
here the same problem.
How to detect the tab that is closing?
 
Mirko


Posted By: cmaxmedia
Date Posted: 01 May 2015 at 6:48am
Hi, i have the same Problem: how to detect the tab id/index that is being closed


Private Sub TabControl1_NavigateButtonClick(ByVal Id As Long, Cancel As Variant)

    MsgBox TabControl1.Selected.Index '<- Nup, thats the active, not the closing tab index!!

End Sub


Posted By: olebed
Date Posted: 03 May 2015 at 6:46am
Hi cmaxmedia,

This strange solution was because in first implementation of TabManager there was only one set of navigation buttons for all tabs (separately in tab header). Then navigate buttons were added for every tab, but NavigateButtonClick event stayed the same.

I fixed it by adding reference to closed TabControlItem in NavigateButtonClick event. Fix will be available from next beta or final release. 



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net