c# - issue with setting focus not working -


i have screen user enters in text box name of location. click on button open group box has 3 textboxes firstname, lastname , pw. trying set focus firstname text box when user clicks button make group box visible (on main form). not set focus (txtbxnamefirst.focus();)

requirement

i understood following:

  • user writes text locationtextbox , clicks button locationsavebutton

  • after clicking button groupboxcontrol should set visible , firstnametextbox shall receive focus

the code

the button clicked after entereing location locationbutton has click event code

private void locationbutton_click(object sender, eventargs e) {     // value textbox location     string location = locationtextbox.text;     // make groupbox visible     groupbox1.visible = true;     // set focus textbox firstname     firstnametextbox.focus();            } 

simple demo windows forms

this how application looks before clicking button

windows forms

after clicking groubbox set visible , other textboxes visible , focus set firstnametextbox

enter image description here


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -