Eto Forms Question Regarding Event Handler

Hi,

I am trying to construct an event handler for an Eto Form that will work in common with a number of controls. Only problem is determining which control made the call. Any way to determine where the call to the function came from. I can only tell that it is a textbox, checkbox, etc. but I need to know the name of the control as well.

def OnSelectedIndexChanged(self, sender, e):
    type = str(sender)
    if type == "Eto.Forms.Label":
        print('Label Changed')
    if type == "Eto.Forms.TextBox":
        print('TextBox Changed')    
    elif type == "Eto.Forms.CheckBox":
        print('CheckBox Changed') 
    elif type == "Eto.Forms.ComboBox":
        print('ComboBox Changed') 
    elif type == "Eto.Forms.DropDown":
        print('Drop Down Changed')  

Thanks in advance.

Eric

Most ETO controls have an ID property that you can populate.

Forgive me but I’m not sure how one would do this? Is this a property that can be accessed through the sender to the handler function?

Eric

self.m_combobox = forms.ComboBox()
self.m_combobox.ID = “1”

def OnSelectedIndexChanged(self, sender, e):
type = str(sender)
if type == “Eto.Forms.ComboBox (1)”:
print “Yay, it’s combobox 1”

1 Like

Thank you so much Travis. This is perfect.

Eric

1 Like