विधि 1
Private Sub Form_Load()
WebBrowser1.Navigate "http://www.google.com/"
Do
Thread.Sleep(100)
Loop While webBrowser1.IsBusy = True
End Sub
Private Sub Command1_Click()
WebBrowser1.Document.All("q").focus 'Set focus to the search text field
End Sub
Private Sub Command2_Click()
WebBrowser1.Document.All("btnI").focus 'Set focus to the google "I Am feeling lucky button"
End Sub
विधि 2
मैं इस MSDN thread: Focus issues with System.Windows.Controls.WebBrowser
तो टेक्स्ट बॉक्स या बटन को webBrowser.Document.ActiveElement.Focus()
में ActiveElement बदलना होगा से VB.Net करने के लिए इसे बदल दिया।
Public Partial Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
Dim host As New WindowsFormsHost()
im webBrowser As New WebBrowser()
host.Child = webBrowser
elementHost1.Child = host
webBrowser.Navigate(New Uri("http://www.google.com"))
Me.Activated += Function() Do
Console.WriteLine(Me.ActiveControl)
If webBrowser.Document <> Nothing Then
If Me.ActiveControl = elementHost1 AndAlso webBrowser.Document.ActiveElement <> Nothing Then
webBrowser.Document.ActiveElement.Focus()
End If
End If
End Function
End Sub
End Class
विधि 3
एक और तरीका है HTML में यह करने के लिए, उदाहरण के लिए हो सकता है:
OnLoad="document.myform2.mybutton.focus();">
स्रोत
2012-06-24 04:38:47
"मेरा कोड अक्षम है" का क्या अर्थ है? क्या आपको एक त्रुटि संदेश मिलता है?वास्तव में क्या होता है? जब आप 'if adtxt.Text' लाइन पर ब्रेक पॉइंट के साथ डीबगर का उपयोग करते हैं तो यह क्या करता है? –
आप इस कोड को कहां डाल रहे हैं? – Ryan
टैब कुंजी का उपयोग न करें, मैं आपको WebBrowser नियंत्रण –