Hi,
How does one run a function immediately following a user selection in a combo box? (Click Event or Update Event?)
Eric
Hi,
How does one run a function immediately following a user selection in a combo box? (Click Event or Update Event?)
Eric
I did not. Do you have a example code snippet?
Eric
Is this anything like Windows Form Code? Can I model the functions in this manner.
Eric
See the following sample:
– Dale
Thanks. I’ll check it out.
Eric
Thank you Dale. I see you handle this like a Windows form with similar syntax. Really appreciate the help!!!
Follow up question to the last:
In the event handler function, based on a user selection how would one go about changing the text on a form label? What would the syntax be?
Thanks Eric
Dale,
Thank you again!!! This is perfect.
Eric
Dale,
Is there a way to set up a single handler function with a variable that will tell you which control was accessed? The sender only tells you what type of control was clicked and not which control was clicked. I want to set up single handler function and I need to know which control was accessed.
Here’s the function I am trying to set up. I need to know which control was activated as well as the type? Is this possible?
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')
Eric
Why do you want to do this, as not all controls have the same events? For example, a label doesn’t have a selected index changed event.
– Dale
I’ll give the function a more generic name. I want to use it to change labels and the like based on choices made or information entered. The if elif statements will take care of the work once I know which control made the call and the value of the control. I did get a suggestion from someone else that I could assign an ID to a control and then pull that information once I’m in the function.
I’m just trying to minimize the number of functions is all.
Eric
Dale
To expand a little further I am creating a user form class that will allow me to pass in a list which will in turn create the userform without having to build the code each time I want a new form. For example: I’ll pass in [‘TextBox’,’txtb_1’,None] which will tell the class to construct a textbox with the name txtb_1 with value of None. I’ve got a basic class started and working. Working now on retrieving the information.
In one of my sections I use the Tag
property to handle them all in one handler:
I think you can use that Tag property to keep track of your components and do with them what you please.
Where do you access the tag property? This is a control property?
as far as I remember every label
, radio button
, button
, etc in WinForms also has the Tag
property
Ivelin,
I do see this now. Another user told me to use the ID property which seems to work as well. I suppose for my purposes both will work.
Thanks for letting me know,
Eric