Hi!!
I create a button foreach process that has a main window! for example :
int x = 0; // the x coordonate for positioning the button
Process[] pros = Process.GetProcesses();
foreach(Process b in pros)
{
if (b.MainWindowTitle.Length > 0)
{
buton = new Button();
panel1.Controls.Add(buton);
buton.Name = "buton";
buton.Text = b.MainWindowTitle;
buton.Size = new Size(150, 28);
buton.Location = new Point(x, 0);
buton.Click += new System.EventHandler(this.statusbar_b_click);
buton.BackColor = System.Drawing.Color.Transparent;
buton.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
buton.FlatAppearance.BorderSize = 0;
buton.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
buton.ForeColor = System.Drawing.SystemColors.ButtonHighlight;
buton.TabIndex = 4;
buton.UseVisualStyleBackColor = false;
buton.BackgroundImage=(Image)(res.GetObject("buton"));
buton.MouseEnter += new EventHandler(this.statusbar_b_over); // help me here
x += 152;
}
}
and now let say that i have created 4 buttons
and here is my mouse click method:
private void statusbar_b_over(object sender, EventArgs e)
{
// how can i know the button that has mouse over are change the background image (i`m intersted in knowing what button was click)
// coz all the buttons point in this method!!
}
Thanks!!!!

please help with this!!!
CRathjen - MSFT
private void statusbar_b_over(object sender, EventArgs e)
{
if (((Button)sender).Name=="button1")
MessageBox.Show("Button1 Clicked");
}
vln
Just to make the case clear (since you haven't closed the question)
The 'sender' IS your Button, that is the button which you have pressed, so in order to get to it's method, you'll have to cast it to it's type, Button
private void statusbar_b_over(object sender, EventArgs e)
{
Button b = sender as Button; // if sender is NOT a button, it will be null
if (b!=null) // that is, it's a button
b.BackgroundImage = new Bitmap("whatever filename or whatever");
}
JakeG1018
You can set the tag property of the buttons if you need some way to label them, and check this in your method, by casting sender to be a Button and checking it.