FormApplication Help
I made a form application and when the form is started it looks like the button is clicked this causes a bad image I set the background color of the button from the code but it doesnt work please help

22 Replies
Can you define "it doesnt work", please?
It's a little tricky without the context.
Yeah very 👍, I am wondering if they mean form on start up the Language button is the active.
When the form runs the "Language" button is automatically selected but this happens only visually no code block works my goal is to fix this visuality
Look for the I believe the Focus property in the code. Long time since I worked with form logic.
Is that button the default for the form?
I tried Label.Focus() but this did not solve the problem
Button and Label are two different things
What does it mean
Would calling the focus function on an invisible button solve the problem
Sounds like you need to study up on what events and properties their are on buttons. If you have the button set to invisible then no Focus will not make it visible. Set it to visible.
It seems to me your question was more of how do I start my form and not have any of the buttons highlighted until they have been clicked?
Yeah
Is this a windows Form app?
Yeah .NET 4.7.2
What ide are you using? Time for an upgrade maybe?
Visual studio 2022
Windows Forms automatically gives focus to the first focusable control on the form, which is usually the first button.
The best I can I find to help you is to create a label to use as on form startup to have focus, and set this labels properties Visible=false and TabStop=false for tabbing abilities.
Then in the form load set the mysomeLabel.Focus(). Yeah a hack around way.
I made the visible value of the language button false then I made the tabstop value false then I called label2.Focus() then I opened the view of the language button but still not solved
You do not need to set those on the language button. Leave it as it was. Your creating a label for the purpose of just making it the focused control on the form. Put it on the form somewhere out of the way, nobody will ever see it, I use to do it with a image that was just pixel in size the same color as the background.
Can you tell me step by step exactly how I should do this
Create a label put it on the form name it what ever you want. Maybe myFocused_lbl
Set the properties for this control as a
I stated earlier
Then in the form load event you add to the top of the code block
myFocused_lbl.Focus();
Where you put this at the top will depend on what you may already have coded in the load event of the form.
I will create a label then give it a name then call label.Focus() during the form loading process
If thats all I have to do then the problem is still not solved
Ill send a video
Sorry, but you clearly do not read well. Maybe someone else can give you some insight. I'm out
Okay