PDA

View Full Version : Trying to make DotNet TabControl for the first time....


Jon-Huhn
01-31-2008, 06:30 PM
Do you need to do something other than create the TabControl, create a TabPage, and add it to the TabControl? I can't seem to get it to work. Here's my attempt:

rollout MyTestRollout "My Test Rollout" (
local myTab=dotNetObject "System.Windows.Forms.TabControl"

fn setupTabs = (
for x=1 to 3 do (
local tabPge=dotNetObject "System.Windows.Forms.TabPage" ("Tab "+x as string)
myTab.Controls.Add tabPge
)
)
on MyTestRollout open do setupTabs()
)
createDialog MyTestRollout width:200 height:200



I expected to at least see three tabs sitting on my rollout, and nothing else. But I don't even see that.

Eric-Harvey
01-31-2008, 08:20 PM
you need to define the dotnetObject as a UI element.

so instead of the line

local myTab=dotNetObject "System.Windows.Forms.TabControl"

use

dotNetcontrol myTab "System.Windows.Forms.TabControl"

RustyKnight
01-31-2008, 10:48 PM
Eric is correct (but he doesn't need me to tell him that ;)), but Bobo did a really cool example of how to use this type of control, which I immeditatly ripped off and have been using...

So basically, once you've set everything up (as per Eric's suggestion and your original code), you need need to do one more thing...set up what is to be displayed when a tab is selected.

What I did was add a subrollout control "beneth" the tab control and when ever the tab selection changes, I call function setTab iIndex =
-- Make sure that the current tab is not the previously selected tab
if iLastSubRollout != (iIndex) do (

-- Check to see if we are already displaying a control or not
if iLastSubRollout != undefined then (

-- Clean up the subrollout control
for subroll in lstRolloutTabs[iLastSubRollout] do
removeSubRollout sroTabs subroll

)

-- Now, this is the really cool part!
-- The array of rollouts actually contains an array of rollouts...
-- ie #(#(roPage01), #(roPage02_01, roPage02_02))
-- This means that the tab page can actually represent a number
-- of different rollouts per page!!
for subroll in lstRolloutTabs[iLastSubRollout = iIndex] do (

addSubRollout sroTabs subroll

)


)

)This function will basically take an array of rollouts and, depending on the selected tab index, display the appropriate rollout in the subrollout control...

All credit goes to Bobo!! Unbeliviably inspired and cool piece of code!

Shane

Bobo
01-31-2008, 11:06 PM
All credit goes to Bobo!! Unbeliviably inspired and cool piece of code!


The original code was written for ActiveX controls and used in the Submit Max To Deadline script we ship with Deadline. Once we had to support Max 9 64, I converted it into DotNet control. Here is what it looks like:

http://www.franticfilms.com/software/support/deadline/images/3dsmax_integrated.png

Jon-Huhn
01-31-2008, 11:42 PM
Thanks, everyone, you've given me a great headstart and hopefully greatly reduced the number of dents I will put in the wall from banging my head against it.

I've never worked with sub-rollouts before, I'll give those and shot and I might be back with some questions targeted at that if I'm having problems.

Thanks all.

CGTalk Moderation
01-31-2008, 11:42 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.