C
C#7d ago
illusDev

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
No description
22 Replies
Patrick
Patrick7d ago
Can you define "it doesnt work", please? It's a little tricky without the context.
glhays
glhays7d ago
Yeah very 👍, I am wondering if they mean form on start up the Language button is the active.
illusDev
illusDevOP7d ago
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
glhays
glhays7d ago
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?
illusDev
illusDevOP7d ago
I tried Label.Focus() but this did not solve the problem
glhays
glhays7d ago
Button and Label are two different things
illusDev
illusDevOP7d ago
What does it mean Would calling the focus function on an invisible button solve the problem
glhays
glhays7d ago
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?
illusDev
illusDevOP7d ago
Yeah
glhays
glhays7d ago
Is this a windows Form app?
illusDev
illusDevOP7d ago
Yeah .NET 4.7.2
glhays
glhays7d ago
What ide are you using? Time for an upgrade maybe?
illusDev
illusDevOP7d ago
Visual studio 2022
glhays
glhays7d ago
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.
illusDev
illusDevOP7d ago
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
glhays
glhays7d ago
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.
illusDev
illusDevOP7d ago
Can you tell me step by step exactly how I should do this
glhays
glhays7d ago
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.
illusDev
illusDevOP7d ago
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
illusDev
illusDevOP7d ago
glhays
glhays7d ago
Sorry, but you clearly do not read well. Maybe someone else can give you some insight. I'm out
illusDev
illusDevOP7d ago
Okay

Did you find this page helpful?