How in C# to pass a name of the object as a parameter to function? -


I have a code that changes the status of the boolean property on the mouseclick, depending on the name of the clicked object: < / P>

  Private Zero Grid_MouseLeftButtonDown (Object Sender, MouseButtonEventArgs E) {Framework Element feSource = eSource FrameworkElement; Switch (feSource.Name) {case "r1s1": if (r1s1.Isselected == incorrect) r1s1.Isselected = true; Other r1s1. This is selected = false; break; Case "r1s2": if (r1s2.Isselected == incorrect) r1s2.Isselected = true; Other r1s2.Iselected = false; break; .............} e.handle = true; }  

I would like to do the same work passing through the sender's name (r1s1, r1s2, .. and so on), where there is a parameter to perform this function where this string is a The name combines with the name (IsSelected) just to customize the code (such as the idea):

  Private Zero Grid_MouseLeftButtonDown (Object Sender, MouseButtonEventArgs E) {Framework Element feSource = eSource FrameworkElement ; ChangeSelection (feSource.Name)} Public Zero ChangeSelection (name of string) {if (name.IsSelected == false) name.Isselected = true; other names. Selected = false; }  

Please correct me, am I doing wrong?

I'm not awesomes on WPF, but I believe that you want to pass feSource its Change the selection in turn, then put it on the "real" type, whether it is a checkbox or else modify it. Selected property on this

I do not know that when you get the reality, you want to name it in the form of the object (object sender).


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -