|
-
May 13th, 2010, 04:37 AM
#1
Problem on setfocus
Hi everybody,
I have a project which contains two forms.
One form contains a combobox and a datagridview control
2nd form contains a textbox and a command button and several Radio Buttons.
When I run the programme the 1st Form is loaded and it is displaying with a combobox and datagridview
If I select somethings from combobox the system showing 2nd form with three type ofcontols(textbox,command
button,radio buttons etc) on top of form No one.
Now I am selecting some radio buttos and clicking command button for execution some job then the 2nd form is closed and
1st form's datagrid view displaying some records and set focus goes to combobox not in gridview. as result
I can't do anything on gridview.
although I have written setfocus on gridview but still the focus goes to combo box
why setfocus is going to combo box instead of gridview.
Please suggest me how to setfocus on to gridview after clicking command button of 2nd form.
//Code
commandbutton_click
1stForm.Datagridview.focused()
//Code
Thanking you
Debasis
-
May 13th, 2010, 06:26 AM
#2
Re: Problem on setfocus
Maybe something else wrong, because this works perfectly :
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim frm2 As New Form2
frm2.Show()
frm2.DataGridView1.Focus()
End Sub
-
May 13th, 2010, 08:18 AM
#3
Re: Problem on setfocus
//Code
commandbutton_click
1stForm.Datagridview. focused()
//Code
The Focused() statement checks to see if the object has focus.
To set the focus to an object you use
Always use [code][/code] tags when posting code.
-
May 13th, 2010, 08:45 AM
#4
Re: Problem on setfocus
 Originally Posted by DataMiser
The Focused() statement checks to see if the object has focus.
To set the focus to an object you use
Good eyes! 
Guess I didn't see it properly as Debasis Bag didn't put the the code in [CODE] tags, which has been asked a million times already.
Debasis, please, use [CODE] tags; it is explained here :
http://www.codeguru.com/forum/showthread.php?t=403073
It is really not difficult, and really not too much to ask of you...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|