I am setting focus to combobox as combobox.select() in a thread by using the delegate. But only after changing the ALT+TAB to another window the combobox is getting focused.

How to solve this problem...

Please help me...

Thanks in advance...

The code is here...
=============

Private Delegate Sub cmbusersetfocus()
Private Sub combouser()
If Me.InvokeRequired Then
' if operating on a thread, invoke a delegate
' on the UI thread.
Dim omd As cmbusersetfocus = New cmbusersetfocus(AddressOf combouser)
Dim arx As IAsyncResult = Me.BeginInvoke(omd)
Me.EndInvoke(arx)

If cmbuser.Focus = False Then

cmbuser.Select()

End If

'cmbuser.Focus()
'Form1.Activate()


' End If

'MsgBox("test")

Return

End If
End Sub

Did you try ComboBox.Focus()

yea I tried combobox.focus But it doesnt work for me...
Is there any other way to bring the focus back to combobox ..

Put ComboBox.Select(); in the form_load event handler.

Thanks.....

I don't need to focus the combobox not in the load... I need to do it after doing some process in thread...

After that a message box appears at the end of the thread... After clicking the ok button in the message box i need to focus the combobox...

At the end of the thread i need to focus it...
So i am using the delegate function to focus the combobox....

After going to some other window only it's get focusing...

When i do the ALT+TAB and go to some other window and when i come back to the form its getting focused....

Please help me....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.