ScriptSpot

Forum topic · General Scripting

Change editable text for System.Windows.Forms.ComboBox

By 3dwannab · 2016-08-23

Description

Hi,

Does anyone know if its possible to change the

dl.SelectedIndex = -1

to non editable text and the rest of the indexes to editable ones.

I want 'Press 'Enter' to rename.mse' to be disabled and the rest to be editable text.

if theTopRollout != undefined then (destroyDialog theTopRollout)

--define variables & globals
global theTopRollout -- This is needed so that you can access your dropdownlist from outside of the rollout
coronaVFBDir = getDir #scripts
default_text = "Press 'Enter' to rename.mse"


try destroyDialog theTopRollout catch()
rollout theTopRollout "Top Rollout"
(

	dotNetControl dl_exrHistory "System.Windows.Forms.ComboBox" text:default_text height:20 width:210 pos:[5,5]


	fn fn_RefreshEXRList = ( -- collects exrs and sorts them
		-- Collect the exrs into an array by paths & name
		intfilesArr = coronaVFBDir + "\*.mse"
		filesArr = getFiles intfilesArr
		if filesArr.count != 0 then (
			sort filesArr
			latestEXR = coronaVFBDir + filenameFromPath filesArr[filesArr.count]

			VFBexrFilenames = for f in filesArr collect (getFilenameFile f) --//Collect all file names in the specified folder directory
		) else VFBexrFilenames = #()
		dl_exrHistory.items.clear() -- Clears ComboBox list before rebuilding
		dl_exrHistory.items.addrange VFBexrFilenames -- Build a new ComboBox list using the view array
-- 		insertItem "Coronas VFB History:" VFBexrFilenames 1
		dl_exrHistory.text = VFBexrFilenames[1]
	)

	on dl_exrHistory open do (
	fn_RefreshEXRList()
	) --Fill on open
	
	on dl_exrHistory DropDown do (
		fn_RefreshEXRList()
	) --Fill on expanding the list

)

createDialog theTopRollout 220 70
Comments (3)

3dwannab · 2016-08-24

Thanks very much mate.

Always a joy to get a great answer from you :)

`

pixamoon · 2016-08-24

Hey,

try to use DropDownStyle - on dl_exrHistory SelectedIndexChanged do

so on open change style to:


dl_exrHistory.DropDownStyle = (dotNetClass "System.Windows.Forms.ComboBoxStyle").DropDownList

when selection changed (SelectedIndexChanged) change it to


dl_exrHistory.DropDownStyle = (dotNetClass "System.Windows.Forms.ComboBoxStyle").DropDown

`

pixamoon · 2016-08-24

here is a sample:


default_text = "Press 'Enter' to rename.mse"
 
try(destroyDialog ::theTopRollout)catch()
rollout theTopRollout "Top Rollout"
(
	dotNetControl dl_exrHistory "System.Windows.Forms.ComboBox" height:20 width:210 pos:[5,5]
 
	on theTopRollout open do (
		dl_exrHistory.DropDownStyle = (dotNetClass "System.Windows.Forms.ComboBoxStyle").DropDownList
		dl_exrHistory.items.addrange #(default_text, "Item 1", "Item 2")
		dl_exrHistory.selectedIndex = 0
	
	) --Fill on open
 
	on dl_exrHistory DropDown do (
		dl_exrHistory.items.clear() 
		dl_exrHistory.items.addrange #("Item 1", "Item 2")

	) --Fill on expanding the list
	
	on dl_exrHistory SelectedIndexChanged do 
		if dl_exrHistory.items.item[dl_exrHistory.selectedIndex] != default_text then dl_exrHistory.DropDownStyle = (dotNetClass "System.Windows.Forms.ComboBoxStyle").DropDown
 
)
createDialog theTopRollout 220 70