[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 108
  • Last Modified:

Why source code for first button affect source code of the other button ?

I am writing my first C# Program in Microsoft Visual C# 2010 Express.  From "New Project" window, I select "Visual C#", "Windows Forms Application".  I create two buttons.  When I write the source code for first button, it propagates to source code of second button.  

Why ?

I need both button's source code to be independent of each other.
0
naseeam
Asked:
naseeam
1 Solution
 
Mike EghtebasDatabase and Application DeveloperCommented:
Could you post the code you have?

By propagate, do you mean to say that you change first code for the first button and the code for the 2nd button changes by itself?

Mike
0
 
Fernando SotoCommented:
Hi naseeam;

In order to answer a question like this on we would need to see the code, can you please post it.

Thanks;
Fernando
0
 
anarki_jimbelCommented:
Very, very strange... Try to clean the solution before editing and  building it...
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Perhaps you had both buttons selected at the same time (by holding down the shift key when clicking on them) and then you assigned a handler to the Click() event using the lightning bolt icon in the Properties Pane?  This would assign the same click handler to all currently selected buttons.
0
 
naseeamAuthor Commented:
Yes, I thought changing code for the first button changes code for the second button.  But there is only one source code file for both buttons.

I tried to clean solution before editing and building because I thought there are separate source code files for each button.  But there is only one source code for both button.

Everything is working fine.  Thanks for everyone's help.




/* Source code after double-clicking Button1 */

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SimpleProgram
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }
    }
}

Open in new window



/* I wrote body of following function */

 private void button1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("You clicked on the Red Button", "Red Button");
        }

Open in new window



/* Following is code after double-clicking second button */

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SimpleProgram
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("You clicked on the Red Button", "Red Button");
        }

        private void button2_Click(object sender, EventArgs e)
        {

        }
    }
}

Open in new window



/* I wrote body of following function */

private void button2_Click(object sender, EventArgs e)
        {
            MessageBox.Show("You clicked on the Blue Button", "Blue Button");
        }
0
 
naseeamAuthor Commented:
I found the problem myself.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now