how to set focus a control in c#
-
I used the flwing code to focus a control. But i got nothing. why? private void button1_Click(object sender, EventArgs e) { if (lst1.Items.Count > 0) { lst2.Items.Add(lst1.SelectedItem); lst1.Items.Remove(lst1.SelectedItem); } if (lst1.CanFocus) { lst1.Focus(); } } rgds, stephen myint
-
I used the flwing code to focus a control. But i got nothing. why? private void button1_Click(object sender, EventArgs e) { if (lst1.Items.Count > 0) { lst2.Items.Add(lst1.SelectedItem); lst1.Items.Remove(lst1.SelectedItem); } if (lst1.CanFocus) { lst1.Focus(); } } rgds, stephen myint
There is an design paradox here: To have this event, you need to click the buttom which forces the focus onto the button. If it was anywhere else, you wouldn't be able to click the button. You don't want things stealing focus while doing various operations (like clicking, drag-and-drop, etc) anyway. You should consider another UI design instead of trying to have focus jump around on the form while performing user input.
-
I used the flwing code to focus a control. But i got nothing. why? private void button1_Click(object sender, EventArgs e) { if (lst1.Items.Count > 0) { lst2.Items.Add(lst1.SelectedItem); lst1.Items.Remove(lst1.SelectedItem); } if (lst1.CanFocus) { lst1.Focus(); } } rgds, stephen myint
-
I used the flwing code to focus a control. But i got nothing. why? private void button1_Click(object sender, EventArgs e) { if (lst1.Items.Count > 0) { lst2.Items.Add(lst1.SelectedItem); lst1.Items.Remove(lst1.SelectedItem); } if (lst1.CanFocus) { lst1.Focus(); } } rgds, stephen myint
U can use Javascript client side scripting for setting focus "Aim to go where U have never been B4 and Strive to achieve it" http://groups.yahoo.com/subscribe/dotnetforfreshers http://himabinduvejella.blogspot.com