TabControl.InsertItem |
Post Reply |
Author | |
Jean
Senior Member Joined: 11 December 2006 Status: Offline Points: 110 |
Post Options
Thanks(0)
Posted: 30 May 2008 at 3:54am |
I like to dynamiccally fill a TabControl with items and TabPages.
On the pages I like to load Controls. I use WinApi SetParent for this. This is the Gui of my test application: I can create the Items, Pages and Controls. If you switch the TabPages, everything looks fine But if you click on a TextBox and then on the underlaying tabPage the TabControl is confused and doesen't show the page content proper. Test: 1.) click the AddPage button twice 2.) select the second TabPage (new 1) 3.) click AddControl 4.) click inside the new control (the textbox) 5.) click below on the TabPage I guess using SetParent causes the problem. Is there another way to create and draw the TabControl + Child-Controls dynamically? uploads/20080530_035238_Sample.zip |
|
Oleg
Admin Group Joined: 21 May 2003 Location: United States Status: Offline Points: 11234 |
Post Options
Thanks(0)
|
Hello,
You can try avoid using TabControlPage, just add new controls to form/tabcontol and show/hide them if user change selected tab
tabControl.InsertItem tabControl.ItemCount, "New " & tabControl.ItemCount, 0, 0
...
Call SetParent(dynTxt(dynTxt.Count - 1).hWnd, tabControl.hWnd)
|
|
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS |
|
Jean
Senior Member Joined: 11 December 2006 Status: Offline Points: 110 |
Post Options
Thanks(0)
|
This seems to work. Thank you!
Now I have to write code to do what I thought the TabControl is doing. But I guess the TabControl+TabControlPages have not been developped for my "special case". |
|
Krog
Groupie Joined: 06 February 2008 Status: Offline Points: 100 |
Post Options
Thanks(0)
|
Hi!
I would like to use the TabControlPage for the same purpose and I am getting the same problem. I am using the following line instead of SetParent:
How can I solve it? Note: I don't want to do the TabControlPage work and also I want the TabControlPage background that we don't get using a frame or picturebox... And the TabControlPages may be created at runtime. Can someone help me? |
|
Product: Xtreme SuitePro (ActiveX) version 15.2.1
Platform: Windows XP SP2 Language: Visual Basic 6 SP6 |
|
Krog
Groupie Joined: 06 February 2008 Status: Offline Points: 100 |
Post Options
Thanks(0)
|
I was testing a workaround using an array of TabControlPages using the Index property at design time but a bug occurs and no one control is displayed, and only one TabControlPage is displayed, empty.
The solution was: -not to use the Index property at design time to create the array; -use an array in the code and assign it at run-time, like this: Dim TabCtlPage() As TabControlPage Private Sub Form_Load() Dim i As Integer ReDim TabCtlPage(0 To 5) Set TabCtlPage(0) = TabControlPage1 Set TabCtlPage(1) = TabControlPage2 Set TabCtlPage(2) = TabControlPage3 Set TabCtlPage(3) = TabControlPage4 Set TabCtlPage(4) = TabControlPage5 Set TabCtlPage(5) = TabControlPage6 ' The tabs that are not being used, we hide: TabControl1.Item(3).Visible = False TabControl1.Item(4).Visible = False TabControl1.Item(5).Visible = False End Sub But I am still preferring to create the TabControlPages at run-time and use an array. So the solution is welcome. |
|
Product: Xtreme SuitePro (ActiveX) version 15.2.1
Platform: Windows XP SP2 Language: Visual Basic 6 SP6 |
|
Xander75
Senior Member Joined: 26 April 2007 Status: Offline Points: 353 |
Post Options
Thanks(0)
|
Hi Jean & Krog,
I stumbled across this post recently as I looked for an answer here in the forums, I know this is a bit late in the day from when you originally posted but I have found a solution and thought I should share it. I too faced the issue with using the TabControlPage but I manged to find a solution that allows you to add new Tabs dynamically and any controls, in my case I was using the ReportControl. The solution is to avoid using the TabControlPage and instead use a PictureBox as the container, I also avoid using the SetParent API. Please see the code below and the attached sample project for the solution. Code Preview: Dim lIndex As Long Private Sub Command1_Click() ' Increment the lIndex variable lIndex = lIndex + 1 ' Load a new picReport Container and rpcReport ReportControl Load picReport(lIndex) Load rpcReport(lIndex) ' Insert the picReport Container into a new tab tabReport.InsertItem lIndex, "New " & lIndex, picReport(lIndex).hWnd, 0 tabReport.SelectedItem = lIndex ' Set the rpcReport ReportControl container to be the picReport Container Set rpcReport(lIndex).Container = picReport(lIndex) ' Resize the rpcReport ReportControl to fit the picReport Container rpcReport(lIndex).Move 0, 0, picReport(lIndex).Width, picReport(lIndex).Height rpcReport(lIndex).Visible = True ' Add Column Configs Dim Column As ReportColumn Set Column = rpcReport(lIndex).Columns.Add(0, "Name", 200, True) ' Add Data to Grid Dim Record As ReportRecord Set Record = rpcReport(lIndex).Records.Add Record.AddItem "Grid " & CStr(lIndex) ' Refresh the rpcReport ReportControl rpcReport(lIndex).Populate End Sub I hope this helps someone... uploads/20100509_041040_DynamicTabs_.zip |
|
Krog
Groupie Joined: 06 February 2008 Status: Offline Points: 100 |
Post Options
Thanks(1)
|
Years later I was with the same problem and I found this thread with my own comments! I didn't even remember of them.
Well, I solved it using a Codejock GroupBox with Transparent=True (and removing the Caption and with no borders) on top of the TabControlPage It works like a charm
|
|
Product: Xtreme SuitePro (ActiveX) version 15.2.1
Platform: Windows XP SP2 Language: Visual Basic 6 SP6 |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |