Forum General

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

How do I make this code simpler?

Yusuf_AYusuf_A Member ✭✭

Hi

I always need to access the properties of other buttons, I know there's a simpler way to do it.

In this example I want to mark one button and unmark other buttons

            button01.BorderWidth = 0;
            button2.BorderWidth = 0;
            button3.BorderWidth = 0;
            button4.BorderWidth = 0;
        button5.BorderWidth = 0;
            button6.BorderWidth = 0;

            // add border to this button
            Button btn = (Button)sender;     
            btn.BorderWidth = 3;
            btn.BorderColor = Color.Blue;

So how can I make this code simpler?
Thank you in advance.

Tagged:

Answers

  • JohnHJohnH GBMember ✭✭✭✭✭

    Add all the buttons to a list and iterate the full list to set the border width to zero, then set the specific button as required?

Sign In or Register to comment.