Click here to Skip to main content
15,923,083 members
Home / Discussions / C#
   

C#

 
GeneralDifferent Guffa Pin
Expert Coming11-Jul-05 7:39
Expert Coming11-Jul-05 7:39 
GeneralRe: Mass Coding Pin
Luis Alonso Ramos10-Jul-05 13:57
Luis Alonso Ramos10-Jul-05 13:57 
GeneralRe: Mass Coding Pin
Expert Coming10-Jul-05 13:59
Expert Coming10-Jul-05 13:59 
GeneralRe: Mass Coding Pin
DavidNohejl10-Jul-05 14:06
DavidNohejl10-Jul-05 14:06 
GeneralRe: Mass Coding Pin
Expert Coming10-Jul-05 14:13
Expert Coming10-Jul-05 14:13 
GeneralRe: Mass Coding Pin
Luis Alonso Ramos10-Jul-05 14:16
Luis Alonso Ramos10-Jul-05 14:16 
GeneralRe: Mass Coding Pin
Luis Alonso Ramos10-Jul-05 14:25
Luis Alonso Ramos10-Jul-05 14:25 
GeneralRe: Mass Coding Pin
Luis Alonso Ramos10-Jul-05 14:13
Luis Alonso Ramos10-Jul-05 14:13 
The envent handler has two parameters: Object sender and EventArgs e. The first represents the object that raised the event. In this case, if you have several objects attached to the same event handler, you should use this parameter to distinguish.

Say you have 3 pictures boxes: pictureBox1, pictureBox2 and pictureBox3. You set the event handlers like this:
pictureBox1.Click += new EventHandler(pictureBox_Click);
pictureBox2.Click += new EventHandler(pictureBox_Click);
pictureBox3.Click += new EventHandler(pictureBox_Click);
Then you only have one event handler:
private void pictureBox_Click(object sender, EventArgs e)
{
    // Display file dialog, get the selected file name, and load the image into
    // the image variable.
    OpenFileDialog openDialog = new OpenFileDialog()
    ....
 
    Image image = Image.FromFile(openDialog.FileName);
 
    // Set the image of the picture box that was clicked
    ((PictureBox) sender).Image = image;
}
I hope this explains it better.

-- LuisR



Luis Alonso Ramos
Intelectix - Chihuahua, Mexico

Not much here: My CP Blog!

GeneralRe: Mass Coding Pin
Expert Coming10-Jul-05 14:21
Expert Coming10-Jul-05 14:21 
GeneralDONE Pin
Expert Coming10-Jul-05 14:26
Expert Coming10-Jul-05 14:26 
GeneralRe: DONE Pin
Luis Alonso Ramos10-Jul-05 14:28
Luis Alonso Ramos10-Jul-05 14:28 
GeneralFile Ops: Windows Service vs. EXE Pin
ahfong10-Jul-05 13:24
ahfong10-Jul-05 13:24 
GeneralRe: File Ops: Windows Service vs. EXE Pin
Dave Kreskowiak10-Jul-05 14:49
mveDave Kreskowiak10-Jul-05 14:49 
GeneralRe: File Ops: Windows Service vs. EXE Pin
ahfong10-Jul-05 15:46
ahfong10-Jul-05 15:46 
GeneralRe: File Ops: Windows Service vs. EXE Pin
Vasudevan Deepak Kumar10-Jul-05 19:50
Vasudevan Deepak Kumar10-Jul-05 19:50 
GeneralRe: File Ops: Windows Service vs. EXE Pin
Dave Kreskowiak11-Jul-05 1:46
mveDave Kreskowiak11-Jul-05 1:46 
Generaltextboxes Pin
mihai_152910-Jul-05 13:13
mihai_152910-Jul-05 13:13 
GeneralRe: textboxes Pin
Christian Graus10-Jul-05 13:37
protectorChristian Graus10-Jul-05 13:37 
GeneralRe: textboxes Pin
mihai_152910-Jul-05 23:40
mihai_152910-Jul-05 23:40 
GeneralRe: textboxes Pin
Christian Graus11-Jul-05 13:05
protectorChristian Graus11-Jul-05 13:05 
GeneralA question about ListBoxes... Pin
Lord Kixdemp10-Jul-05 10:57
Lord Kixdemp10-Jul-05 10:57 
Generalshallow/deep copy-- I give up...... Pin
...---...10-Jul-05 6:42
...---...10-Jul-05 6:42 
GeneralRe: shallow/deep copy-- I give up...... Pin
S. Senthil Kumar10-Jul-05 6:50
S. Senthil Kumar10-Jul-05 6:50 
GeneralRe: shallow/deep copy-- I give up...... Pin
leppie11-Jul-05 0:54
leppie11-Jul-05 0:54 
GeneralRe: shallow/deep copy-- I give up...... Pin
S. Senthil Kumar11-Jul-05 1:25
S. Senthil Kumar11-Jul-05 1:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.