下拉列表框下拉时及关闭下拉时显示不同 text 的实现 (VS2010)
下拉列表框下拉时及关闭下拉时显示不同 text 的实现 (VS2010)
---- ---- class cewcombobox ---- ----
public class newcombobox
inberits combobox
public sub init(byval list as list(of string))
for each item as string in list
me.items.add(new newitem with {.value=item})
next
end sub
protected overrides sub ondropdown
flag.closed=true
me.refreshitems
end sub
protected overrides sub ondropdownclosed
flag.closed=false
me.refreshitems=false
end sub
end class
---- ---- class flag ---- ----
public class flag
public shared closed as boolean
end class
---- ---- class newitem ---- ----
public class newitem
public value as string
public overrides function tostring as string
if flag.closed
return value
else
return value.split("(")(0)
endif
end function
end class
---- ---- class testform ---- ----
class testform
sub main
dim list as new list(of string)
for i as integer = 0 to 9
list.add(i.tostring & "(" & i.tostring & ")")
next
me.newcombobox1.init(list)
end sub
end class