Help Please!: Webbrowser control and changing size

Is there a way to make, If a toolbar is not visible make webbrowser co

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 12542 Views - Last Post: 14 September 2009 - 01:23 AM Rate Topic: -----

#1 yapper99  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 20-August 08

Help Please!: Webbrowser control and changing size

Post icon  Posted 20 August 2008 - 02:47 PM

I am creating a program with a web browser component, and a tab control. Default, the web browser is anchored to the toolbar. In my program there is an option to make a toolbar at the top of the form visible.false. Is there a way to make the web browser anchor to the top of the tab control when the toolbar is not visible, and anchor to the toolbar when the toolbar is visible?? I have experimented with docking (fill) but then parts of the web browser become covered by the toolbar and status bar. I am still relatively new to visual basic 2008 so if you could please explain or provide code that would be greatly appreciated!

Thanks a lot in advance,

Is This A Good Question/Topic? 0
  • +

Replies To: Help Please!: Webbrowser control and changing size

#2 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2267
  • View blog
  • Posts: 9,480
  • Joined: 29-May 08

Re: Help Please!: Webbrowser control and changing size

Posted 20 August 2008 - 03:10 PM

Can you post a picture as i find it hard to visualize the layout.
Was This Post Helpful? 0
  • +
  • -

#3 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2267
  • View blog
  • Posts: 9,480
  • Joined: 29-May 08

Re: Help Please!: Webbrowser control and changing size

Posted 20 August 2008 - 03:37 PM

Have you though about doing it with code rather that anchor and dock
If Me.ToolStrip.Visible Then
 ' Tool Strip is visible so attach to bottom of toolstrip
 me.WebbrowserControl.Top=Me.ToolStripBottom
Else
 ' Tool Strip is not visible so attach top to top of form
 Me.WebBrowserControl.Top=Me.Top
endif


Was This Post Helpful? 0
  • +
  • -

#4 yapper99  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 20-August 08

Re: Help Please!: Webbrowser control and changing size

Posted 20 August 2008 - 03:41 PM

View PostAdamSpeight2008, on 20 Aug, 2008 - 03:10 PM, said:

Can you post a picture as i find it hard to visualize the layout.


Sure! at the top you can see that the toolbars is not visible but the web browser does not expand to fill the empty space and so all you see is the background color of the form.. what I want to do is make it so that the webbrowser expands to asnchor to the tabcontrol when the toolbars are not visible and anchors to the of the bottom toolbar when the toolbars are visible.

Attached image(s)

  • Attached Image

Was This Post Helpful? 0
  • +
  • -

#5 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2267
  • View blog
  • Posts: 9,480
  • Joined: 29-May 08

Re: Help Please!: Webbrowser control and changing size

Posted 20 August 2008 - 04:04 PM

View Postyapper99, on 20 Aug, 2008 - 11:41 PM, said:

View PostAdamSpeight2008, on 20 Aug, 2008 - 03:10 PM, said:

Can you post a picture as i find it hard to visualize the layout.


Sure! at the top you can see that the toolbars is not visible but the web browser does not expand to fill the empty space and so all you see is the background color of the form.. what I want to do is make it so that the webbrowser expands to asnchor to the tabcontrol when the toolbars are not visible and anchors to the of the bottom toolbar when the toolbars are visible.

Try using
If Me.ToolStrip.Visible Then
 ' Tool Strip is visible so attach to bottom of toolstrip
 me.WebbrowserControl.Top=Me.ToolStrip.Bottom
 Me.WebbrowserControl.Height-=Me.ToolStrip.Height
Else
 ' Tool Strip is not visible so attach top to top of form
 Me.WebBrowserControl.Top=Me.TabStrip.Bottom
 Me.WebbrowserControl.Height+=Me.ToolStrip.Height

Endif


This post has been edited by AdamSpeight2008: 20 August 2008 - 04:10 PM

Was This Post Helpful? 0
  • +
  • -

#6 yapper99  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 20-August 08

Re: Help Please!: Webbrowser control and changing size

Posted 20 August 2008 - 04:17 PM

Will I have to remove the property anchors because I have tried both ways but sill it is not working? I have tried messing around with the code but sill nothing happens when i make the toolbar visible.false and when i switch back.... could it be an anchor property i.e webbrowser2.anchor........

thanks
Was This Post Helpful? 0
  • +
  • -

#7 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2267
  • View blog
  • Posts: 9,480
  • Joined: 29-May 08

Re: Help Please!: Webbrowser control and changing size

Posted 20 August 2008 - 04:46 PM

View Postyapper99, on 21 Aug, 2008 - 12:17 AM, said:

Will I have to remove the property anchors because I have tried both ways but sill it is not working? I have tried messing around with the code but sill nothing happens when i make the toolbar visible.false and when i switch back.... could it be an anchor property i.e webbrowser2.anchor........

thanks

Remove the anchors and dock (set them to none)
Put the code in the ToolStrip1.VisibleChanged event
Was This Post Helpful? 0
  • +
  • -

#8 yapper99  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 20-August 08

Re: Help Please!: Webbrowser control and changing size

Posted 20 August 2008 - 05:16 PM

[/quote]
Remove the anchors and dock (set them to none)
Put the code in the ToolStrip1.VisibleChanged event
[/quote]

i don't seem to sound noobish but how do that is it a Private sub...
Was This Post Helpful? 0
  • +
  • -

#9 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2267
  • View blog
  • Posts: 9,480
  • Joined: 29-May 08

Re: Help Please!: Webbrowser control and changing size

Posted 20 August 2008 - 05:29 PM

View Postyapper99, on 21 Aug, 2008 - 01:16 AM, said:


Remove the anchors and dock (set them to none)
Put the code in the ToolStrip1.VisibleChanged event
[/quote]

i don't seem to sound noobish but how do that is it a Private sub...
[/quote]
The private means it can be access from within the form.
Score of Variable Tutorial

    Private Sub ToolStrip1_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStrip1.VisibleChanged
        If Me.ToolStrip1.Visible Then
            ' Tool Strip is visible so attach to bottom of toolstrip
            Me.WebBrowser2.Top = Me.ToolStrip1.Bottom
            Me.WebBrowser2.Height -= Me.ToolStrip1.Height
        Else
            ' Tool Strip is not visible so attach top to top of form
            Me.WebBrowser2.Top = Me.TabPage1.Bottom
            Me.WebBrowser2.Height += Me.ToolStrip1.Height
        End If
    End Sub


Was This Post Helpful? 0
  • +
  • -

#10 yapper99  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 20-August 08

Re: Help Please!: Webbrowser control and changing size

Posted 20 August 2008 - 06:06 PM

    Private Sub ToolStrip1_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStrip1.VisibleChanged
        If Me.ToolStrip1.Visible Then
            ' Tool Strip is visible so attach to bottom of toolstrip
            Me.WebBrowser2.Top = Me.ToolStrip1.Bottom
            Me.WebBrowser2.Height -= Me.ToolStrip1.Height
        Else
            ' Tool Strip is not visible so attach top to top of form
            Me.WebBrowser2.Top = Me.TabPage1.Bottom
            Me.WebBrowser2.Height += Me.ToolStrip1.Height
        End If
    End Sub


[/quote]


the height changing code works great but the thing is it changes the height from both the bottom and the top....so when the program default starts the webbrowser is not the proper height...also the Me.WebBrowser2.Top = Me.TabPage1.Bottom and Me.WebBrowser2.Top = Me.ToolStrip1.Bottom do not seem to work??



sorry i forget to add this......here is my slightly altered code


 If Me.ToolStrip4.Visible = False Then
			Me.WebBrowser2.Top = Me.TabPage1.Top
			Me.WebBrowser2.Height += Me.ToolStrip4.Height And Me.ToolStrip6.Height
		Else
			If ToolStrip4.Visible = True Then
				Me.WebBrowser2.Height -= Me.ToolStrip4.Height And Me.ToolStrip6.Height
				Me.WebBrowser2.Top = Me.ToolStrip4.Bottom
			End If

		End If


Was This Post Helpful? 0
  • +
  • -

#11 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2267
  • View blog
  • Posts: 9,480
  • Joined: 29-May 08

Re: Help Please!: Webbrowser control and changing size

Posted 20 August 2008 - 06:14 PM

View Postyapper99, on 21 Aug, 2008 - 02:06 AM, said:

 If Me.ToolStrip4.Visible = False Then
			Me.WebBrowser2.Top = Me.TabPage1.bottom
			Me.WebBrowser2.Height += Me.ToolStrip4.Height
		Else
			If ToolStrip4.Visible = True Then
				Me.WebBrowser2.Height -= Me.ToolStrip4.Height 
				Me.WebBrowser2.Top = Me.ToolStrip4.Bottom
			End If

		End If



Change the names to the name of the control you are using.

This post has been edited by AdamSpeight2008: 20 August 2008 - 06:16 PM

Was This Post Helpful? 0
  • +
  • -

#12 yapper99  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 20-August 08

Re: Help Please!: Webbrowser control and changing size

Posted 20 August 2008 - 06:17 PM

[/quote]

Change the names to the name of the control you are using.
[/quote]

I changed the names to fit my project i.e. toolstrip 6...... is that what you mean?
Was This Post Helpful? 0
  • +
  • -

#13 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2267
  • View blog
  • Posts: 9,480
  • Joined: 29-May 08

Re: Help Please!: Webbrowser control and changing size

Posted 20 August 2008 - 06:32 PM

View Postyapper99, on 21 Aug, 2008 - 02:17 AM, said:



Change the names to the name of the control you are using.
[/quote]

I changed the names to fit my project i.e. toolstrip 6...... is that what you mean?
[/quote]
yes
Was This Post Helpful? 0
  • +
  • -

#14 yapper99  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 41
  • Joined: 20-August 08

Re: Help Please!: Webbrowser control and changing size

Posted 24 August 2008 - 01:22 PM

View PostAdamSpeight2008, on 20 Aug, 2008 - 06:32 PM, said:

View Postyapper99, on 21 Aug, 2008 - 02:17 AM, said:



Change the names to the name of the control you are using.


I changed the names to fit my project i.e. toolstrip 6...... is that what you mean?
[/quote]
yes
[/quote]

I did everything but the code just won't work properly


	Private Sub ToolStrip9_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStrip9.VisibleChanged

		If Me.ToolStrip9.Visible Then
			Me.WebBrowser3.Top = Me.ToolStrip9.Bottom
			Me.WebBrowser3.Height -= Me.ToolStrip9.Height And Me.ToolStrip8.Height
		Else

			Me.WebBrowser3.Top = Me.TabPage2.Top
			Me.WebBrowser3.Height += Me.ToolStrip9.Height And Me.ToolStrip8.Height
		End If
	End Sub




firstly when the application is started up the web browser is not the proper size because the height is reduced
Me.WebBrowser3.Height -= Me.ToolStrip9.Height And Me.ToolStrip8.Height


secondly for some reason even though it states
Me.WebBrowser3.Top = Me.ToolStrip9.Bottom
the top of the webbrowser goes to the top of the toolstrip and therefore covers the toolstrip?

also i have toolstrips 8 and 9.....

thanks,
Was This Post Helpful? 0
  • +
  • -

#15 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2267
  • View blog
  • Posts: 9,480
  • Joined: 29-May 08

Re: Help Please!: Webbrowser control and changing size

Posted 24 August 2008 - 01:42 PM

Why do you keep using the logic statement?
Me.ToolStrip9.Height And Me.ToolStrip8.Height

Private Sub ToolStrip9_VisibleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStrip9.VisibleChanged
If Me.ToolStrip9.Visible Then
 Me.WebBrowser3.Top = Me.ToolStrip9.Bottom
 Me.WebBrowser3.Height -= Me.ToolStrip9.Height
Else
 Me.WebBrowser3.Top = Me.TabPage2.Bottom
 Me.WebBrowser3.Height += Me.ToolStrip9.Height
		End If
	End Sub



In then FormLoad Event
Me.ToolStrip9.visible=true


Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2