Notifications
Clear all

[Closed] .NET button props in max rollout

Hi all,
I have some problems with “.visible ” property in dotnet button in max rollout
When I toggle it on and off it stay visible, but not active.
Other button properties like “pos” work well/
Example:

(
	rollout Roll "Wtf" width:241 height:86
	(
		checkbutton btn1 "PressMe" pos:[8,7] width:100 height:30
		button btn2 "I see You" pos:[131,7] width:100 height:30 
		checkbutton btn3 "PressMeToo" pos:[8,40] width:100 height:30
		dotNetControl btnNet "button" pos:[131,40] width:100 height:30
		
		on btn1 changed state do btn2.visible = not state 
		on btn3 changed state do btnNet.visible = not state 
	)
	createdialog roll
)

7 Replies

on btn1 changed state do if state then btn2.visible = false else btn2.visible = true

something is broken in dotnetcontrol visibility. there is a workaround. make a dotnet button as dotnetobject and add it to dotnetcontrol. this way the visibility works.

try(destroydialog dialog) catch()
rollout dialog "Toggle Visibility" width:200
(
	checkbutton show_bt "Show >>" width:80 across:2
	dotnetcontrol panel "UserControl" width:80 height:22 
	
	local bt
	on show_bt changed state do bt.Visible = not state
	on dialog open do
	(
		bt = dotnetobject "Button"
		bt.Text = "Dotnet"
		bt.Dock = bt.Dock.Fill
		panel.controls.add bt
	)
)
createdialog dialog
1 Reply
(@lonerobot)
Joined: 10 months ago

Posts: 0

Ah, nice, I’d found the visible property not working before, i’d got around it by adding and subtracting 1000 to the pos.x property on the checkbox handler. Yours is better.

rollout dialog "Toggle Visibility" width:200
(
	checkbutton show_bt "Show >>" width:80 across:2 checked:true
	dotnetcontrol bt "button" width:80 height:22 
	on show_bt changed state do bt.pos.x += if state then 1000 else -1000 
)
createdialog dialog

DotNet in dotnet in dotnet :arteest:
Panel, yep, I tried it, but not this way. Your method works perfectly.
Thank you.

i’m sure i posted another solution for this some time ago using reflection to set the corrrect property, maybe it was for the enabled property. either way i’ll try track it down and post a link.

EDIT: found the thread but it was only about getting the enabled property. here’s the link anyway:
http://forums.cgsociety.org/showthread.php?f=98&t=927555

 lo1

The problem you have here is the opposite.

Changing the .visible state of the dotnetControl calls the getter/setter of System.Windows.Forms.Control.Visible. What we need to do is force it to call the getter/setter of MAXScript UI item .visible.

Thank you guys for interesting solutions, I get it