-2

I'm creating an application in Forms for very non tech-savvy users. In doing so, I'm attempting to keep some more complicated buttons and menus hidden in the main program unless an invisible checkbox is checked- which only the QA/Dev team would need to use for troubleshooting.

I've attempted to use checkBox1.Hide() followed by checkBox1.Show on click as well as on CheckedChanged, however when the checkbox is hidden or has visibile set to false, the checkbox is unable to be checked. I've also looked at the checkbox's properties window in the Form design, but setting the bordercolor to white or the bordersize to 0 under FlatAppareance had no effect.

Any suggestions? Thanks for the help.

Bright
  • 3
  • 1
  • If I understand you correctly you are trying to use an user interface element to change the behavior and appearance of your application. Isn't it better to use some other methods? A configuration option for example or just the presence of a particular file or a command line parameter? – Steve Jul 08 '19 at 20:07
  • @Steve I'm certain there's better solutions to enabling a developer menu, but the method of implementing this is out of my control. I was asked for an invisible button/checkbox. – Bright Jul 08 '19 at 20:10
  • 1
    Maybe you should tell your boss or whoever asked you to do that, that this is not the way to go for something like this. Having a configuration xml file for example is much more suitable. In the end you are the expert implementing this so there is no reason why you shouldn't tell the on who gave you that task what would work best. Besides that I don't think it is possible off my head to have a invisible but clickable button. – Mirko Brandt Jul 08 '19 at 20:19
  • An invisible clickable checkbox. sounds weird... lol anyways, maybe this might help: https://stackoverflow.com/questions/17979781/how-can-i-hide-a-checkbox-in-html – jPhizzle Jul 08 '19 at 20:21
  • @jPhizzle that link you provide is `javascript` this question is `winforms`. – Franck Jul 08 '19 at 20:22
  • 1
    @jPhizzle Seemed promising, but in winforms opacity applies to the form and all of it's controls. There's no way that I am aware of for setting the opacity of a specific control to 0 while keeping the others and the form around it visible. – Bright Jul 08 '19 at 20:23
  • @Franck whoops.. thought he was referring to WebForms – jPhizzle Jul 08 '19 at 20:24
  • @Bright my bad. sorry i couldn't be of service hehe – jPhizzle Jul 08 '19 at 20:25
  • @Bright Anything invisible will never trigger a click event. You need a very custom handmade control with more state and draw it by hand. Or you do it like you should and put it visible only to the people that can use it. – Franck Jul 08 '19 at 20:27

1 Answers1

0

I agree with the comments this is not a good practice when designing a user interface, but there is a way to make an invisible button in winforms.

in your constructor or in a method set the properties of the button like so

  button1.FlatStyle = FlatStyle.Flat;
  button1.FlatAppearance.BorderColor = BackColor;
  button1.FlatAppearance.MouseOverBackColor = BackColor;
  button1.FlatAppearance.MouseDownBackColor = BackColor;

this will render a invisible to the user button that can be clicked. that is if your click event is already set up.

Reese Jones
  • 181
  • 8