Link to home
Start Free TrialLog in
Avatar of Cro0707
Cro0707Flag for Croatia

asked on

Focus on listbox (VB2005)

Simple form, on form there is one tab control. In first tab control, I have one list box called Lst_Job. What I want, when programs start that Lst_Job has focus.

But no, it doesn't go so easy. I put Lst_Main.Focus() in Form_Load but no luck.

WTF??! In VB6 is was so easy.

Also, If I have tabcontrol, how can I set shortcut button for each tab, like J&ob, &Private, etc?
Avatar of TaeSoft
TaeSoft

Have you tried to set the taborder to 0 in the properties?
Avatar of Cro0707

ASKER

Yes, it is 0.
Avatar of Jorge Paulino
Set on the tabcontrol Tabstop = false
You can also do Lst_Job.SelectedIndex = 0 to show the first file selected
ASKER CERTIFIED SOLUTION
Avatar of TaeSoft
TaeSoft

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Cro0707

ASKER

This is just workaround for my problem.

This works (jpaulino) but I also need keyboard access to tabs... Wht this simple option doesn't work?!?

Form_Load

   Lst_Job.focus ()

?!?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Cro0707

ASKER

OK TeaHard, your solution works...

But I still need solution for second part of my question... Enyone? (250x4 is for TeaHard already)
As I sad before, if you whant to do that you must capture the keypress event to do the job.
Hi,
put this after a button:
   tabControl1.SelectedIndex = 1;

//The selectindex is the TabPage you want on top.

If you want to use KeyBoard triggers, see jpaulino also

Thanks.