Notifications
Clear all

[Closed] dotNet ListView + struct problem

Hey guys, I have a maxscript question if you have a moment.

     I’m basically setting up a dotNet listview  struct that I can stick in seamlessly to any rollout or other code.
   
     I’m getting an odd hang up at the bottom in the line “ [font=Arial]ListObj = new_ListView()[/font]” with the error, [i]name expected [/i].
   
     [color=White]Changing the last 2 lines to:[/color]
local  ListObj = new_ListView()
 --     ListObj.setup()
      Instead of this:
ListObj = new_ListView()
      ListObj.setup()
     , for whatever reason fixes that error,  and then running the line 
theRollout.ListObj.setup() 
     in the listener works fine. So I’m assuming its just some simple syntax error that’s goofing me up but I can’t see it. Could you take a look when you have a moment?
  
  Here's the optimized code:
(
     try(DestroyDialog theRollout)catch()
     
     global theRollout
     
       rollout theRollout "The Rollout" width:144 height:348
       (
     	
     	dotNetControl dotNetListView "system.windows.forms.listView" 	pos:[11,20]	height:100
     	
     
     	struct Pallete_lv
     	(
     		-- Properties
     		--//===============
     			this,							-- pointer to the class
     			ListView = dotNetListView,
     					 
     											
     		-- 	Methods
     		--//===============
     			fn init selfRef =
     				(
     					selfRef.this = selfRef
     				),
     	
     			fn Setup =
     				(		
     					List_ = this.ListView
     					
     				--// Listview Parameters	
     					List_.Height			= 133
     					List_.Width				= 121
     					
     				--// DotNet Class Usage
     					FormsStyle 				= (dotNetClass "System.Windows.Forms.view")
     					CursorStyle				= (dotNetClass "System.Windows.Forms.Cursors.Hand")
     					BorderStyle				= (dotNetClass "System.Windows.Forms.BorderStyle")
     		
     				--// Setup Look of ListView
     					List_.FullRowSelect		= true						-- Highlights full row of item selected.
     					List_.GridLines			= true						-- Show lines between the items.
     					List_.MultiSelect		= false						-- Only single selections.
     					List_.Scrollable		= false						-- makes it so the list view isn't scrollable
     					List_.LabelEdit 		= true						-- allows the user to change the labels.
     					List_.ShowItemToolTips	= true						-- allows tool tips to be show.
     					
     					List_.Cursor 			= CursorStyle				-- Changes to hand when inside controller
     					List_.BorderStyle		= BorderStyle.FixedSingle	-- how the borders of the controller is displayed	
     					List_.view 				= FormsStyle.details		-- displays view as a detailed list.	
     					
     				--// Declare inital columns 	--Fn Call--
     					this.addColumns	 List_	#( #("Object",78),#("Type",43) )
     					
     				),
     			
     			fn addColumns lv	columnArray  =
     				(
     					for property in columnArray do						-- columns are 0 based numbering.
     						lv.columns.add  property[1] property[2]
     				)
     				
     	)-- end struct
     		
     		--// Call this to create the ListView.
     		fn new_ListView =
     		(	
     				ref = Pallete_lv()
     				ref.init ref	-- sets up self reference
     			
     				return ref
     		);
     		
     		local ListObj = new_ListView()
     		--ListObj.setup()
     	
        ) -- end rollout
     
     CreateDialog theRollout pos:[188,602]
2 Replies

I think you can’t have that declaration inside the rollout without being inside some event handler… I’ve changed it and it worked, here you go.

(
     try(DestroyDialog theRollout)catch()
     
     global theRollout
     
       rollout theRollout "The Rollout" width:144 height:348
       (
     	local ListObj
     	dotNetControl dotNetListView "system.windows.forms.listView" 	pos:[11,20]	height:100     	
     
     	struct Pallete_lv
     	(
     		-- Properties
     		--//===============
     			this,							-- pointer to the class
     			ListView = dotNetListView,
     					 
     											
     		-- 	Methods
     		--//===============
     			fn init selfRef =
     				(
     					selfRef.this = selfRef
     				),
     	
     			fn Setup =
     				(		
     					List_ = this.ListView
     					
     				--// Listview Parameters	
     					List_.Height			= 133
     					List_.Width				= 121
     					
     				--// DotNet Class Usage
     					FormsStyle 				= (dotNetClass "System.Windows.Forms.view")
     					CursorStyle				= (dotNetClass "System.Windows.Forms.Cursors.Hand")
     					BorderStyle				= (dotNetClass "System.Windows.Forms.BorderStyle")
     		
     				--// Setup Look of ListView
     					List_.FullRowSelect		= true						-- Highlights full row of item selected.
     					List_.GridLines			= true						-- Show lines between the items.
     					List_.MultiSelect		= false						-- Only single selections.
     					List_.Scrollable		= false						-- makes it so the list view isn't scrollable
     					List_.LabelEdit 		= true						-- allows the user to change the labels.
     					List_.ShowItemToolTips	= true						-- allows tool tips to be show.
     					
     					List_.Cursor 			= CursorStyle				-- Changes to hand when inside controller
     					List_.BorderStyle		= BorderStyle.FixedSingle	-- how the borders of the controller is displayed	
     					List_.view 				= FormsStyle.details		-- displays view as a detailed list.	
     					
     				--// Declare inital columns 	--Fn Call--
     					this.addColumns	 List_	#( #("Object",78),#("Type",43) )
     					
     				),
     			
     			fn addColumns lv	columnArray  =
     				(
     					for property in columnArray do						-- columns are 0 based numbering.
     						lv.columns.add  property[1] property[2]
     				)
     				
     	)-- end struct
     		
     		--// Call this to create the ListView.
     		fn new_ListView =
     		(	
     				ref = Pallete_lv()
     				ref.init ref	-- sets up self reference
     			
     				return ref
     		)
     		
     		on theRollout open do
			(
				ListObj = new_ListView()
				ListObj.setup()
			)
     	
        ) -- end rollout
     
     CreateDialog theRollout pos:[188,602]
	)

Thanks,

i did something similar after posting and it worked as well, i was waiting to see if someone saw something i was missing.

Thanks for your time and help.