Web browser help

Help with my web browser

Page 1 of 1

10 Replies - 1993 Views - Last Post: 11 January 2009 - 04:09 AM Rate Topic: -----

#1 developerman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 28-March 08

Web browser help

Posted 09 January 2009 - 01:19 PM

i implemented a web browser but I have an issue with my homepage

I try to set homepage using

  CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(My.Settings.Homepage) 


and get an error saying homepage is not a member of the windowsapplication1.My.MySettings, how do I fix this.
Is This A Good Question/Topic? 0
  • +

Replies To: Web browser help

#2 dklingman  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 263
  • Joined: 23-December 08

Re: Web browser help

Posted 09 January 2009 - 01:41 PM

start with checking the settings tab of the MyProject. if that's ok delete it and recreate it.
Was This Post Helpful? 0
  • +
  • -

#3 developerman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 28-March 08

Re: Web browser help

Posted 09 January 2009 - 01:45 PM

View Postdklingman, on 9 Jan, 2009 - 12:41 PM, said:

start with checking the settings tab of the MyProject. if that's ok delete it and recreate it.


where is the settings tab?
Was This Post Helpful? 0
  • +
  • -

#4 dklingman  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 263
  • Joined: 23-December 08

Re: Web browser help

Posted 09 January 2009 - 01:56 PM

Posted Image
Was This Post Helpful? 0
  • +
  • -

#5 developerman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 28-March 08

Re: Web browser help

Posted 09 January 2009 - 02:04 PM

ahhh thanks yeah found it and what exactly do i do from here now to rectify my problem?

(sorry for being a pain in the ass but once i get this glitch fixed i am literally done home and dry)
Was This Post Helpful? 0
  • +
  • -

#6 dklingman  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 33
  • View blog
  • Posts: 263
  • Joined: 23-December 08

Re: Web browser help

Posted 09 January 2009 - 02:15 PM

In the settings is there a setting name called Homepage? If so delete it and recreate it. Also make sure that the value is set as well.

how did you originally create the My.Settings.Homepage ?
Was This Post Helpful? 0
  • +
  • -

#7 Core  Icon User is offline

  • using System.Linq;
  • member icon

Reputation: 774
  • View blog
  • Posts: 5,097
  • Joined: 08-December 08

Re: Web browser help

Posted 09 January 2009 - 03:29 PM

Make sure that the setting exists. You can't call a setting if the setting is not created. There is no need to remove and add the setting again. Just make sure that the setting supports the data type you are specifying (in your case it is String).
Was This Post Helpful? 0
  • +
  • -

#8 developerman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 28-March 08

Re: Web browser help

Posted 09 January 2009 - 07:02 PM

Thanks for your help there guys, I fixed the issue that occured but now I am having another issue, basically My browser works however in it the function to save the homepage works but when the program is exited and run again the original homepage is shown, I want the user selected homepage to display.

Public Class frmWeb

	Dim i As Integer
	Private Sub NewTabToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewTabToolStripMenuItem.Click
		Dim browse As New WebBrowser
		browse.Name = "b1"
		browse.Dock = DockStyle.Fill
		AddHandler browse.DocumentCompleted, AddressOf browsing_done
		TabControl1.TabPages.Add(i, "page " & i + 1)
		TabControl1.SelectTab(i)
		TabControl1.SelectedTab.Controls.Add(browse)
		i = i + 1

	End Sub
	Dim browse As New WebBrowser

	Private Sub browsing_done(ByVal sender As Object, ByVal e As Windows.Forms.WebBrowserDocumentCompletedEventArgs)
		TabControl1.SelectedTab.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).DocumentTitle
		Me.Text = ("Web Browser - " + CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).DocumentTitle)
		With ToolStripProgressBar1
			.Minimum = 1
			.Maximum = 10000
			.Value = 1
			.Step = 1
			ToolStripProgressBar1.Visible = True
			For i As Integer = .Minimum To .Maximum
				.PerformStep()
			Next i
		End With

		If CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).ReadyState Then
			ToolStripProgressBar1.Visible = False
		End If
		If ToolStripProgressBar1.Value = 10000 Then ToolStripStatusLabel1.Visible = True
		If ToolStripComboBox2.Items.Contains(CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.AbsoluteUri) Then
			ToolStripComboBox2.Text = (CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.AbsoluteUri)
		Else
			ToolStripComboBox2.Items.Add(CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.AbsoluteUri)
			VisitedSitesToolStripMenuItem.DropDownItems.Add(CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.AbsoluteUri)
			ToolStripComboBox2.Text = (CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.AbsoluteUri)
		End If
	End Sub

	Private Sub CloseTabToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseTabToolStripMenuItem.Click
		TabControl1.TabPages.RemoveAt(TabControl1.SelectedIndex)
		i = i - 1
		ToolStripComboBox2.Items.Add((ToolStripComboBox2.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Url.AbsoluteUri))

	End Sub
	Private Sub ToolStripComboBox2__KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ToolStripComboBox2.KeyPress
		If Asc(e.KeyChar) = Keys.Enter Then
			CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(ToolStripComboBox2.Text)
		End If
	End Sub
	Private Sub ToolStripComboBox2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStripComboBox2.SelectedIndexChanged
		CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(ToolStripComboBox2.SelectedItem)
	End Sub

	Private Sub ToolStripButton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton3.Click
		CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(ToolStripComboBox2.Text)

	End Sub

	Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
		CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoBack()

	End Sub

	Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
		CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).GoForward()
	End Sub

	Private Sub frmWeb_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		Dim browse As New WebBrowser
		browse.Name = "b1"
		browse.Dock = DockStyle.Fill
		AddHandler browse.DocumentCompleted, AddressOf browsing_done
		TabControl1.TabPages.Add(i, "page" & i + 1)
		TabControl1.SelectTab(i)
		TabControl1.SelectedTab.Controls.Add(browse)
		i = i + 1
		CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(My.Settings.Homepage)
		ToolStripComboBox1.SelectedItem = "google"



	End Sub

	Private Sub ToolStripButton4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton4.Click
		CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Refresh()
	End Sub

	Private Sub ToolStripButton5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton5.Click
		CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Stop()
	End Sub

	Private Sub MainMenuToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MainMenuToolStripMenuItem.Click
		frmmain.Show()
		Me.Hide()
	End Sub

	Private Sub VideoBowserToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VideoBowserToolStripMenuItem.Click
		frmVid.Show()
		Me.Hide()
	End Sub

	Private Sub ImageBrowserToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ImageBrowserToolStripMenuItem.Click
		frmImg.Show()
		Me.Hide()
	End Sub

	Private Sub ToolStripButton6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton6.Click
		CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(My.Settings.Homepage)

	End Sub

	Private Sub ToolStripButton7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton7.Click
		If ToolStripComboBox1.SelectedItem = "Google" Then
			CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://www.google.com/search?hl=en&q=" + ToolStripTextBox2.TextBox.Text)
		ElseIf ToolStripComboBox1.SelectedItem = "Yahoo" Then
			CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate("http://search.yahoo.com/search?p=" + ToolStripTextBox2.TextBox.Text)
		End If
	End Sub

	Private Sub ChangeHomepageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ChangeHomepageToolStripMenuItem.Click
		frmchange.Show()

	End Sub


	Private Sub DownloadImagesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DownloadImagesToolStripMenuItem.Click
		frmwebdload.Show()
	End Sub

	Private Sub VisitedSitesToolStripMenuItem_DropDownItemClicked(ByVal sender As Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles VisitedSitesToolStripMenuItem.DropDownItemClicked
		CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(VisitedSitesToolStripMenuItem.DropDownItems.ToString)
	End Sub
	Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
		End
	End Sub


End Class


This post has been edited by developerman: 09 January 2009 - 07:09 PM

Was This Post Helpful? 0
  • +
  • -

#9 Core  Icon User is offline

  • using System.Linq;
  • member icon

Reputation: 774
  • View blog
  • Posts: 5,097
  • Joined: 08-December 08

Re: Web browser help

Posted 09 January 2009 - 09:21 PM

I didn't see any part in your code which will handle the setting saving. The setting should be set like this:

My.Settings.Test = "myString
My.Settings.Save()



The string value myString is being assigned to the Test setting. Then you should use Save() to store the modified application settings. You can easily change this code to save your home page.

This post has been edited by Core: 09 January 2009 - 09:21 PM

Was This Post Helpful? 0
  • +
  • -

#10 developerman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 28-March 08

Re: Web browser help

Posted 10 January 2009 - 04:39 PM

The solution worked, my browser is perfect thank you
Was This Post Helpful? 0
  • +
  • -

#11 developerman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 28-March 08

Re: Web browser help

Posted 11 January 2009 - 04:09 AM

ok this problem is unrelated but i thought i would put in here instead of a new thread. For one of my forms I have a tab control and a menu control. on loading the form i want the file menu to be disabled as it is unrelated to the tab on show. I want it so when the next tab is clicked, the menu is enabled and when the previous tab that is unrelated is clicked, the menu is disabled again. I tried these codes

 
	Private Sub frmImg_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		FileToolStripMenuItem.Enabled = False


	End Sub

	Private Sub TabPage2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabPage2.Click
		FileToolStripMenuItem.Enabled = True
	End Sub

	Private Sub TabPage1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabPage1.Click
		FileToolStripMenuItem.Enabled = False
	End Sub



this code does not work how I want because the user would have to click on the actual tab page to enable the menu, I want them to click on the tab to enable and disable the menu

I also tried this but it doesn't do anything hence doesn't work

   Private Sub FileToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FileToolStripMenuItem.Click
		If TabControl1.SelectedIndex.Equals(TabPage2) Then
			Me.Enabled = True
		Else
			Me.Enabled = False
		End If

	End Sub


Does anybody have any ideas on this?

thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1