• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 535
  • Last Modified:

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?
0
Cro0707
Asked:
Cro0707
  • 4
  • 3
  • 3
2 Solutions
 
TaeSoftCommented:
Have you tried to set the taborder to 0 in the properties?
0
 
Cro0707Author Commented:
Yes, it is 0.
0
 
jpaulinoCommented:
Set on the tabcontrol Tabstop = false
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
jpaulinoCommented:
You can also do Lst_Job.SelectedIndex = 0 to show the first file selected
0
 
TaeSoftCommented:
Can you set

Lst_Main.Select();

When you open the form and move with the arrows, do you see the listbox changing?
0
 
Cro0707Author Commented:
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 ()

?!?
0
 
jpaulinoCommented:
For that you have capture the right/left key pressed and select the next/previous tab. If you have the listbox selected you can not select the tabs with the cursor keys.
0
 
Cro0707Author Commented:
OK TeaHard, your solution works...

But I still need solution for second part of my question... Enyone? (250x4 is for TeaHard already)
0
 
jpaulinoCommented:
As I sad before, if you whant to do that you must capture the keypress event to do the job.
0
 
TaeSoftCommented:
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.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

  • 4
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now