The example defines a Product Selection ComboBox Class - connected to an
ExternalDictionary tool.
import CLR
import CLR.System.Windows.Forms as WinForms
from CLR.System.Drawing import Size, Point, Pen, Color, SystemColors
from CLR.System.Drawing import ContentAlignment, Font, FontStyle, Image
class SelectProductCombo(WinForms.ComboBox):
def __init__(self):
pass
def Init(self,nameOfDictionary,nameOfSelection):
self.nameOfDictionary = nameOfDictionary
self.nameOfSelection = nameOfSelection
self.SelectedValueChanged += self.SelectedValueChangedHandler
self.SetProductComboBox()
def SetProductComboBox(self):
plist = GetResultValue(nameOfDictionary)
print plist
list = []
for element in plist:
print element
list.append(element)
print list
list.sort()
for product in list:
self.Items.Add(str(product))
self.Text = str(GetValue(self.nameOfSelection))
# eventhandler
def SelectedValueChangedHandler(self, sender, args):
SetValue(self.nameOfSelection,int(self.Text))
Example 1: Instantiate Product Selection ComboBox
# Create the select product combobox
self.SelectProduct = SelectProductCombo()
self.SelectProduct.Parent = self
self.SelectProduct.Size = Size(150,30)
self.SelectProduct.Location = Point((3*self.Width/2-self.SelectProduct.Width)/2,120)
self.SelectProduct.Font= Font(self.FontName, 16, FontStyle.Bold)
self.SelectProduct.Init(nameOfDictionary,nameOfSelection)
|