dotnet Split Container

dotnet Split Container

ztravnicky
Enthusiast Enthusiast
1,071 Views
3 Replies
Message 1 of 4

dotnet Split Container

ztravnicky
Enthusiast
Enthusiast

I would like to have nested Listviews inside Container (Panel1, Panel2) and have "standard" methods over them. At the end container should be places inside scripted modifier. Unfortunately my attached code doesn't return anything on ItemSelectionChanged method wherever it sits.

Any advice please?

 

try(destroyDialog testR)catch()
rollout testR "Test" width:400 height:400
(
	dotnetcontrol pn "MaxCustomControls.MaxUserControl" width:390 height:390 pos:[5,5] 
	dotnetcontrol lsv1 "Listview" height:50
	dotnetcontrol lsv2 "Listview"
	
	on testR open do 
	(
		lvops.InitListView lsv1 pInitColumns:#("Object") pAllowReorder:false pCheckBoxes:false pLabelEdit:False pInitColWidths:#(50)
		lsv1.dock = lsv1.dock.fill
		
		lvops.InitListView lsv2 pInitColumns:#("Object") pAllowReorder:false pCheckBoxes:false pLabelEdit:False pInitColWidths:#(50)
		lsv2.dock = lsv2.dock.fill
		
		sp1 = dotnetobject "SplitContainer" 
		sp1.dock = sp1.dock.fill
		sp1.splitterWidth = 5
		
		
		sp1.Panel1.controls.add lsv1
		sp1.Panel2.controls.add lsv2
		pn.controls.add sp1

		for i=1 to 10 do (
			lvops.AddLvItem lsv1 pTextItems:#(i as string)
		)
	)
	
	on lsv1 ItemSelectionChanged arg do (		
		format "Item index: % ### Item text: %\n" arg.ItemIndex arg.Item.Text
	)
)
createDialog testR

 

0 Likes
Accepted solutions (1)
1,072 Views
3 Replies
Replies (3)
Message 2 of 4

paulneale
Advisor
Advisor

I missed one detail that I now see and that is the part about it being in a modifier. There is a big problem with dotNet and modifiers as the scope of the UI in a modifier appears to be something special. When you try and use dotNet.addEventHandler to add the events they will not fire. Using a dotNet form directly in the rollout works when you are using the Max script method for adding events. This means that it really isn't possible to do dynamic forms where eventhandlers are being added and removed. 

 

The way that I get around this sort of thing is to have a floating tool that uses the data stored in a modifier to populate it. 

 

This is an example of what you are asking about that really doesn't work well as adding new controls means hard coding them and all their event handlers.

http://www.penproductions.ca/temp/nitasFacialUi.jpg

 

Instead I have moved to a new system like this. 

 

Paul Neale

http://paulneale.com


Paul Neale




EESignature

Message 3 of 4

ztravnicky
Enthusiast
Enthusiast

Interesting, Thanks Paul. Anyway...

 

If I create:

local lsv1=dotNetObject "System.Windows.Forms.Listview"

 function :

fn fPrint = (
format "Item index: % ### Item text: %\n" (lvops.GetLvSingleSelected lsv1).index (lvops.GetLvSingleSelected lsv1).text
)

 


and eventhandler for it :

dotnet.addeventhandler lsv1 "ItemSelectionChanged" fPrint

 



Is there any way to pass argument information to fPrint from "ItemSelectionChanged" standard onEvent situation?

0 Likes
Message 4 of 4

paulneale
Advisor
Advisor
Accepted solution

Arguments are automatically passed for you. Your event functions should look like this. 

 

 

fn mouseUpEvent sender arg =
(
   showProperties sender
   print "---"
   showProperties arg
)
 
bt=dotNetObject "Button"
dotNet.addeventHandler bt "mouseUp" mouseUpEvent

 Sender containts reference to the object that called the event function. arg containts arguments for the event and will be different depending on which event you add. 

 

Does that help?

Paul Neale

http://paulneale.com


Paul Neale




EESignature