5
Hello, I am developing a project of a dental clinic in c# in which uses several buttons inside a picturebox to select the teeth, so I decided to put several Buttons with certain opacity and the result was very satisfactory, the problem is that the opacity properties of a button can only be set in the code itself and not in the VS properties menu. So for that I have to relate all Buttons to picturebox, set the Location of each and set its color and opacity, I wonder if I can at least set the color and opacity of the Buttons at once in just a few lines of code instead of repeating the same for each button.
Follow a piece of what I did as an example, in total would be 32 Buttons, would be a code I believe I unnecessarily large.
button1.BackColor = Color.Transparent;
button1.FlatAppearance.MouseOverBackColor = Color.FromArgb(150, Color.LightBlue);
button1.Parent = pictureBox1;
button1.Location = new Point(28, 90);
button2.BackColor = Color.Transparent;
button2.FlatAppearance.MouseOverBackColor = Color.FromArgb(150, Color.LightBlue);
button2.Parent = pictureBox1;
button2.Location = new Point(55, 90);
button3.BackColor = Color.Transparent;
button3.FlatAppearance.MouseOverBackColor = Color.FromArgb(150, Color.LightBlue);
button3.Parent = pictureBox1;
button3.Location = new Point(80, 90);
button4.BackColor = Color.Transparent;
button4.FlatAppearance.MouseOverBackColor = Color.FromArgb(150, Color.LightBlue);
button4.Parent = pictureBox1;
button4.Location = new Point(112, 90);
That’s what I’m looking for, thank you very much!!!!
– Gabriel Arruda
in this last part of the second suggestion, where do I put button1 = etc? where do I put it from the error "Inaccessible due to its Protection level"
– Gabriel Arruda
@Gabrielarruda Make sure your class/field is public and the builder is also
– Bruno Costa
I have a question, should it create a new button in the form instead of using the existing button1 in the form? when executing button properties are not applied and it creates a new random button.
– Gabriel Arruda
You have to find your boot on
toolbox
. Usually this is only possible if you have a constructor with no arguments, so the button appears ontoolbox
have to build the project. This is why I gave the first solution, I consider it a little simpler.– Bruno Costa
Um, but this is something I don’t quite understand how this works, is there any place that shows it? the friend from the other post said the same thing but I didn’t understand.
– Gabriel Arruda
@Gabrielarruda I hope my question helps and response
– Bruno Costa
helped a lot yes Bruno, thanks a lot for the help and patience!!!! the same question and that it did not appear in my Toolbox, if not, would not be having all this doubt, but for that if I do not find out I open another post, vlw!!!
– Gabriel Arruda