How would I get the button stand on top of other buttons when it is clicked on. I have a form with a button for every character on the computer when I click on a button it gets big but stands behind the other buttons. then I click on the same button again
and it gets small. What I want it to do is stand proud above the other buttons. Could someone please help me? Thank you for your time in advance.Here is the code I have for the form.I didn't give all the buttons to keep it short.
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; using System.Windows.Controls.Primitives; using System.Windows.Controls; using System.Windows; using System.Windows.Media; using System.Windows.Controls.Properties; namespace HexCalcChar { public partial class CharMap : Form { public CharMap() { InitializeComponent(); foreach (System.Windows.Forms.Control control in this.Controls) { System.Windows.Forms.Button button = control as System.Windows.Forms.Button; if (button != null) { button.Click += (sender, e) => { System.Windows.Forms.Button thisButton = sender as System.Windows.Forms.Button; System.Drawing.Size shrunkSize = new System.Drawing.Size(40, 23); System.Drawing.Size grownSize = new System.Drawing.Size(55, 50); thisButton.Size = (thisButton.Size == shrunkSize) ? grownSize : shrunkSize; }; } } } private void CharMap_Load(object sender, EventArgs e) { } private void textBox1_TextChanged(object sender, EventArgs e) { } private void textBox2_TextChanged(object sender, EventArgs e) { } private void textBox3_TextChanged(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { ReSizeButtons(btn1); tb1dec.Text = "0"; tb2hex.Text = "00"; tb3lastclicked.Text = "NUL"; } private void button2_Click(object sender, EventArgs e) { ReSizeButtons(btn2); tb1dec.Text = "1"; tb2hex.Text = "01"; tb3lastclicked.Text = "SOH"; } private void button3_Click(object sender, EventArgs e) { ReSizeButtons(btn3); tb1dec.Text = "2"; tb2hex.Text = "02"; tb3lastclicked.Text = "STX"; } public void ReSizeButtons(System.Windows.Forms.Button txt) { if (txt.Width == 40) { txt.Size = new System.Drawing.Size(40, 23); } else { txt.Size = new System.Drawing.Size(55, 50); } foreach (System.Windows.Forms.Control control in this.Controls) { if (control is System.Windows.Forms.Button) { if (control != txt) { control.Size = new System.Drawing.Size(40, 23); } } } } private void button4_Click(object sender, EventArgs e) { ReSizeButtons(btn4); tb1dec.Text = "3"; tb2hex.Text = "03"; tb3lastclicked.Text = "ETX"; } private void button1_Click_1(object sender, EventArgs e) { ReSizeButtons(btn16); tb1dec.Text = "15"; tb2hex.Text = "0F"; tb3lastclicked.Text = "SI"; }
michael r demulling