Solved

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

Posted on 2015-02-12
6
104 Views
Last Modified: 2015-02-18
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
Comment
Question by:naseeam
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 34

Expert Comment

by:Mike Eghtebas
ID: 40606958
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
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 40607136
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
 
LVL 30

Expert Comment

by:anarki_jimbel
ID: 40607153
Very, very strange... Try to clean the solution before editing and  building it...
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 40607314
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
 
LVL 1

Accepted Solution

by:
naseeam earned 0 total points
ID: 40607825
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
 
LVL 1

Author Closing Comment

by:naseeam
ID: 40616140
I found the problem myself.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question