Solved

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

Posted on 2015-02-12
6
92 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
6 Comments
 
LVL 33

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 62

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 29

Expert Comment

by:anarki_jimbel
ID: 40607153
Very, very strange... Try to clean the solution before editing and  building it...
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 85

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
 

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
 

Author Closing Comment

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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

758 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now