I have a listbox in which user picks an option, and depending on that choice I want to access different fields of some object and perform some manipulation. For example, if user picks an option “Title”, I want my program to perform operations with movie.Title
The only way I had in mind to handle this would be to make one big switch statement in which I would check user’s choice and perform all of the operations according to that choice. In this case, I would have to write almost same code(only difference is which field I use for manipulation) quite a few times, and I’d like to avoid duplicating that quantity of code
Is there some other, more elegant way to do this? I guess using pointers to appropriate fields and assigning them after user selects something would do the job… Is there some other way I can create some kind of “alias” for a field?
I guess all of this sounds very messy, but I hope you got the point.
tnx in advance
The only way I had in mind to handle this would be to make one big switch statement in which I would check user’s choice and perform all of the operations according to that choice. In this case, I would have to write almost same code(only difference is which field I use for manipulation) quite a few times, and I’d like to avoid duplicating that quantity of code
Is there some other, more elegant way to do this? I guess using pointers to appropriate fields and assigning them after user selects something would do the job… Is there some other way I can create some kind of “alias” for a field?
I guess all of this sounds very messy, but I hope you got the point.
tnx in advance