[Closed] Dotnet <> Max Combobox
Hi
Max Combobox is combination of a textbox and editbox, where is implemented automatic search for textbox content rigt ?
Dotnet Combobox looks like a simple dropdown list…(maybe can be modified?)
Is in dotnet something like max combobox? or must be done by two components?
! dotnet ComboBox combines both textbox and dropdown list functionalities.
try(destroydialog cbox) catch()
rollout cbox "ComboBox" width:200 height:23
(
dotnetcontrol ed "ComboBox" pos:[0,1] width:200 height:21
on cbox open do
(
ed.items.addrange #("March","April","May")
)
)
createdialog cbox
I dont know my friend , when I tryed it he drop this error:
OK
Rollout:cbox
– Error occurred in cbox.open()
– Frame:
>> MAXScript Rollout Handler Exception: – Runtime error: No method found which matched argument list <<
true
OK
When I run it with comented this line ed.items.addrange #(“March”,“April”,“May”)
then dialog is open with a simple dropdown list inside?
any sugestions?
Im tryed allso one method which I found on a forum.
Is working , but again , is only a drop down list no listbox below…
try(destroydialog cbox) catch()
rollout cbox "ComboBox" width:200 height:200
(
dotnetcontrol ed "ComboBox" pos:[0,1] width:200 height:21
fn dotNetArray mxsArray =
(
netArray = dotNetObject "System.String[]" mxsArray.count
for i=1 to mxsArray.count do
(
str = dotNetObject "System.String" mxsArray[i]
indx = dotNetObject "System.Int32" (i-1)
netArray.SetValue str indx
)
netArray
)
on cbox open do
(
ed.items.addrange(dotNetArray #("March","April","May"))
)
)
createdialog cbox
Maybe Im not explane it right.
Here is some picture
I want the listbox to be static , not dropable
listbox is not the same as dropdown list
there is no dotnet control that combines textbox and listbox. you have to use two controls.
MerlinEl, may I ask why you are creating dotnet array for combobox? You can use normal maxscript arrays with most dotnet controls.
Hi VVaari
because of this error:
OK
Rollout:cbox
– Error occurred in cbox.open()
– Frame:
>> MAXScript Rollout Handler Exception: – Runtime error: No method found which matched argument list <<
true
OK
Maybe is something with 3DsMax9
And here is it! My first vession of Dotnet Max Combobox
rollout dotnetMaxComboBoxDialog "Combo Box Test:" width:240 height:332
(
dotNetControl textBox "textbox" pos:[8,20] width:224 height:20
dotNetControl listbox "listbox" pos:[8,44] width:224 height:284
fn dotNetArray mxsArray =
(
local netArray = dotNetObject "System.String[]" mxsArray.count
for i=1 to mxsArray.count do
(
local str = dotNetObject "System.String" mxsArray[i]
local indx = dotNetObject "System.Int32" (i-1)
netArray.SetValue str indx
)
netArray
)
fn fillListBox =
(
--generate random array
local upper="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
local lower="abcdefghijklmnopqrstuvwxyz"
local arr = for i = 1 to 100 collect \
upper[random 1 upper.count] +
lower[random 1 upper.count] +
lower[random 1 upper.count] +
lower[random 1 upper.count] +
lower[random 1 upper.count]
listbox.items.addrange(dotNetArray arr)
listbox.Sorted = true
)
fn lowerCase text =
(
local upper="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
local lower="abcdefghijklmnopqrstuvwxyz"
new_text = ""
for i = 1 to text.count do
(
local column = findString upper text[i]
if column == undefined
then new_text += text[i]
else new_text += lower[column]
)
new_text
)
fn compareTexts textArray text ignoreCase:false =
(
for i = 1 to textArray.count do
(
if textArray[i].count < text.count do return 0
local text_part = subString textArray[i] 1 text.count
if ignoreCase do
(
text_part = lowerCase text_part
text = lowerCase text
)
format "text_part:% text:%
" text_part text
if text_part == text do return i
)
return 0
)
fn searchInListbox text =
(
--mc2System.show listbox
local listbox_items = for i = 0 to listbox.Items.Count-1 collect listbox.Items.Item[i]
local row = compareTexts listbox_items text ignoreCase:true
if row != 0 do listbox.SelectedIndex = row-1
)
on dotnetMaxComboBoxDialog open do
(
fillListBox()
setFocus textBox
)
on textBox keyPress arg do
(
--if not backspace pressed
searchInListbox (textBox.text + (if arg.KeyChar != "" then arg.KeyChar else ""))
)
)
createDialog dotnetMaxComboBoxDialog
Currently, this works well.
Im not satisfied with this line ,
searchInListbox (textBox.text + (if arg.KeyChar != “” then arg.KeyChar else “”))
but I cant find nothing better
you can use KeyUp event instead of keyPress
on textBox keyUp arg do
(
searchInListbox textBox.text
)
hi,
i have a simple version for you have a look.
(
rollout dotnetMaxComboBoxDialog "Combo Box Test:" width:240 height:332
(
local items = #()
dotNetControl textBox "textbox" pos:[8,20] width:224 height:20
dotNetControl listbox "listbox" pos:[8,44] width:224 height:284
fn fillListBox =
(
--generate random array
local upper="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
local lower="abcdefghijklmnopqrstuvwxyz"
local arr = for i = 1 to 100 collect \
upper[random 1 upper.count] +
lower[random 1 upper.count] +
lower[random 1 upper.count] +
lower[random 1 upper.count] +
lower[random 1 upper.count]
listbox.items.addrange arr
listbox.Sorted = true
items = arr
)
fn searchInListbox txt =
(
--mc2System.show listbox
tempAry = #()
pat = txt + "*"
for i in items do
(
if matchPattern i pattern:pat do
(
append tempAry i
)
)
tempAry
)
on dotnetMaxComboBoxDialog open do
(
fillListBox()
setFocus textBox
)
on textBox keyUp arg do
(
--if not backspace pressed
txt = textBox.text
list = searchInListbox txt
if txt != "" then
(
listbox.items.clear()
listbox.items.addrange list
if list.count != 0 then listbox.selectedIndex = 0
)
else
(
listbox.items.clear()
listbox.items.addrange items
listbox.selectedIndex = 0
)
)
)
createDialog dotnetMaxComboBoxDialog
)