none
Problem with Control Focus RRS feed

  • Question

  • Using VS2005 VB Express edition but I don'tthink this is edidition specific.

    On my start windows form I want to give a listbox focus after it is filled with data.

    I am using the command listbox1.focus() to do this in the form_load event after processing the data file in.

    Focus is not given to the listbox but another control.  I can refresh the listbox using a filter routine which also ends with the above commmand and it works fine.

    I added a conditional after the simple command

    listbox1.focus()
    if not lisbox1.focused then
         litsbox1.focus()
    end if

    Makes no difference.   Sngle stepping shows that the that the xondition is met (so the listbox has not got the focus) then the focus() command is executed again but still no focus on that listbox.

    BTW I am issuing  listbox1.SelectedIndex = 0 before I call the focus method.  This is working.

    Any suggestions much appreciated.  The problem is not life threatening - just irritating because the first thing my users want to do when the program starts is to navigate the listbox

    thanks in advance
    Wednesday, December 7, 2005 8:45 AM

All replies

  • Set the tabindex of listbox to 1
    may be it is sete as 0

    0 tabindex doesnt works


    regards
    Wednesday, December 7, 2005 9:23 AM
  • Thanks Sanjay

    Tab order was the problem.  Interestingly though tabindex 0 does work.  It was the index 0 control that was getting the focus.  I changed the listbox to 0 and that is now getting it.

    Wednesday, December 7, 2005 9:45 AM