I’m dabbling in C#,and I’m rather inexperienced with it. I have a button with text and an image on it. When I run the program and press the button, the button gets pushed in, along with the text, but the Image stays static.
Does anyone know a workaround?
*EDIT:
this.btnRename.AllowDrop = true;
this.btnRename.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right)));
this.btnRename.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
this.btnRename.Image = ((System.Drawing.Image)(resources.GetObject("btnRename.Image")));
this.btnRename.ImageAlign = System.Drawing.ContentAlignment.TopCenter;
this.btnRename.Location = new System.Drawing.Point(675, 3);
this.btnRename.Margin = new System.Windows.Forms.Padding(0);
this.btnRename.Name = "btnRename";
this.btnRename.Size = new System.Drawing.Size(55, 48);
this.btnRename.TabIndex = 7;
this.btnRename.Text = "&Rename";
this.btnRename.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
this.btnRename.UseVisualStyleBackColor = false;
this.btnRename.Click += new System.EventHandler(this.btnRename_Click);
.NET doesn’t do this for you automatically because it doesn’t know what you expect to happen to the image on button click. Do you expect it to be smaller, moved right, moved left…etc. Perhaps you could implement the MouseDown and MouseUp events? On MouseDown you could have it change the image to what you expect to see for the “pushed in” and change it back on MouseUp. Of course this involves you essentially having 2 images, a “clicking” and an “normal” version.