9Mcode comment |
 |
 |
|
|
|
 |
- - - - - - - - - - - - - - ผู้ให้การสนับสนุน- - - - - - - - - - - - - -
|
|
 |
กระทู้ #2867 [Vb] (จาก IP: 125.24.54.68)
อยากทราบ code กำหนดให้ TextBox สามารถ search ได้เหมือน Google ค่ะ
ต้องการให้ TextBox สามารถขึ้น detail ข้อมูลได้เหมือน Google ค่ะ เวลา search หาข้อมูล เพื่อให้ง่ายต่อการใช้งานค่ะ
ใครมีความรู้ทางด้านนี้ช่วยด้วยนะค่ะ ลองทำแล้วแต่ไม่ได้ซักทีรบกวนด้วยนะค่ะ
ขอบคุณค่ะ
|
จากคุณ
:
sweetfern / sweetfernice@hotmail.com [2010-04-27 13:54:39]
|
|
ความคิดเห็น #27873 (จาก IP: 112.142.186.62)
ศึกษา code vb.net หรือ vs 2008 ดูครับ เรียกใช้ control >> Web browser
โปรแกรมส่วนหนึ่งครับ Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.Width = 700 Me.Height = 600 Me.Text = "Test Browser"
End Sub 'step 1 Private Sub Loadpage(ByVal urlString As String) If String.IsNullOrEmpty(urlString) Then Return If (Not urlString.StartsWith("http://")) Then urlString = "http://" & urlString End If WebBrowser1.Navigate(urlString) End Sub
'step2 Private Sub ToolStripComboBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ToolStripComboBox1.KeyDown If (e.KeyCode = Keys.Enter) Then 'e คือตัวแปรใช้เก็บเหตุการณ์ .keycodeใช้ตรวจสอบว่าจะทำอะไร Loadpage(ToolStripComboBox1.Text) End If End Sub
'step3 Private Sub UpdateComboBoxUrl(ByVal urlstring As String) Dim findUrl As Integer 'ตรวจสอบว่ามีรายการที่ตรงกับค่าตัวแปรที่ส่งไปหรือไม่ หากมีคืนค่ามาเป็นลำดับที่ของรายการ หากไม่มีคืน-1 findUrl = ToolStripComboBox1.FindStringExact(urlstring)
'ถ้ายังไม่มีอยู่ในlist If (findUrl = -1) Then findUrl = ToolStripComboBox1.Items.Add(urlstring)
End If
'ให้urlนี้เป็นรายการที่เลือกอยู่ปัจจุบัน ToolStripComboBox1.SelectedIndex = findUrl End Sub Private Sub WebBrowser1_Navigated(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles WebBrowser1.Navigated 'เมื่อโหลดหน้าwebเสร็จให้ส่งค่าurlนั้นไปให้ โปรแกรมย่อยที่ชื่อUpdateComboBoxUrl UpdateComboBoxUrl(WebBrowser1.Url.AbsoluteUri.ToString()) End Sub
'step4 Private Sub ToolStripComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStripComboBox1.SelectedIndexChanged Dim urlString As String 'แปลงค่ารายการที่ถูกเลือกให้เป็นข้อความ :SelectedItem เป็น object urlString = ToolStripComboBox1.SelectedItem.ToString() 'ถ้า url ที่เลือกในcombobox1ไม่ซ้ำกับหน้าที่แสดงอยู่ปัจจุบันให้นำมาโหลดแสดง If (urlString <> WebBrowser1.Url.ToString()) Then Loadpage(urlString) End If End Sub
'step5 Private Sub WebBrowser1_NewWindow(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles WebBrowser1.NewWindow 'ในเอกสารhtml สิ่งที่เราไปกดคือ <a href="www.aaa.com"><a> If (WebBrowser1.Document.ActiveElement.TagName = "a") Then e.Cancel = True 'ปิดการเปิดด้วย ie เครื่อง
Dim meHref As String = WebBrowser1.Document.ActiveElement.GetAttribute("href") Dim f As New Form1 f.Show() f.Text = meHref f.WebBrowser1.Navigate(meHref) Else e.Cancel = False End If End Sub 'step6 'new window Private Sub NewToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click Dim newwin As New Form1 newwin.WebBrowser1.Navigate(Me.WebBrowser1.Url) newwin.Show()
End Sub 'open Private Sub OpenToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click OpenFileDialog1.Filter = "web page(*.html)|*.html" If (OpenFileDialog1.FileName <> "") Then WebBrowser1.Navigate(OpenFileDialog1.FileName) End If End Sub 'save as Private Sub SaveAsToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SaveAsToolStripMenuItem.Click WebBrowser1.ShowSaveAsDialog() End Sub 'exit
Private Sub ExitToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click Me.Dispose() End Sub End Class |
จากคุณ
:
pt / xxx@xxx.com [2010-05-05 01:57:40]
|
 |
|
- - - - - - - - - - - - - - ผู้ให้การสนับสนุน- - - - - - - - - - - - - -
|
|
|
|
|
|
|