Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 136,299 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 2,463 people online right now. Registration is fast and FREE... Join Now!




Help Please!: Webbrowser control and changing size

2 Pages V  1 2 >  
Reply to this topicStart new topic

Help Please!: Webbrowser control and changing size, Is there a way to make, If a toolbar is not visible make webbrowser co

yapper99
20 Aug, 2008 - 01:47 PM
Post #1

New D.I.C Head
*

Joined: 20 Aug, 2008
Posts: 31

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,

User is offlineProfile CardPM
+Quote Post

AdamSpeight2008
RE: Help Please!: Webbrowser Control And Changing Size
20 Aug, 2008 - 02:10 PM
Post #2

LINQ D.I.C.
Group Icon

Joined: 29 May, 2008
Posts: 799



Thanked: 51 times
Dream Kudos: 2175
My Contributions
Can you post a picture as i find it hard to visualize the layout.
User is offlineProfile CardPM
+Quote Post

AdamSpeight2008
RE: Help Please!: Webbrowser Control And Changing Size
20 Aug, 2008 - 02:37 PM
Post #3

LINQ D.I.C.
Group Icon

Joined: 29 May, 2008
Posts: 799



Thanked: 51 times
Dream Kudos: 2175
My Contributions
Have you though about doing it with code rather that anchor and dock
CODE

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

User is offlineProfile CardPM
+Quote Post

yapper99
RE: Help Please!: Webbrowser Control And Changing Size
20 Aug, 2008 - 02:41 PM
Post #4

New D.I.C Head
*

Joined: 20 Aug, 2008
Posts: 31

QUOTE(AdamSpeight2008 @ 20 Aug, 2008 - 03:10 PM) *

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 thumbnail(s)
Attached Image
User is offlineProfile CardPM
+Quote Post

AdamSpeight2008
RE: Help Please!: Webbrowser Control And Changing Size
20 Aug, 2008 - 03:04 PM
Post #5

LINQ D.I.C.
Group Icon

Joined: 29 May, 2008
Posts: 799



Thanked: 51 times
Dream Kudos: 2175
My Contributions
QUOTE(yapper99 @ 20 Aug, 2008 - 11:41 PM) *

QUOTE(AdamSpeight2008 @ 20 Aug, 2008 - 03:10 PM) *

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
CODE

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 Aug, 2008 - 03:10 PM
User is offlineProfile CardPM
+Quote Post

yapper99
RE: Help Please!: Webbrowser Control And Changing Size
20 Aug, 2008 - 03:17 PM
Post #6

New D.I.C Head
*

Joined: 20 Aug, 2008
Posts: 31

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
User is offlineProfile CardPM
+Quote Post

AdamSpeight2008
RE: Help Please!: Webbrowser Control And Changing Size
20 Aug, 2008 - 03:46 PM
Post #7

LINQ D.I.C.
Group Icon

Joined: 29 May, 2008
Posts: 799



Thanked: 51 times
Dream Kudos: 2175
My Contributions
QUOTE(yapper99 @ 21 Aug, 2008 - 12:17 AM) *

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

User is offlineProfile CardPM
+Quote Post

yapper99
RE: Help Please!: Webbrowser Control And Changing Size
20 Aug, 2008 - 04:16 PM
Post #8

New D.I.C Head
*

Joined: 20 Aug, 2008
Posts: 31


[/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...
User is offlineProfile CardPM
+Quote Post

AdamSpeight2008
RE: Help Please!: Webbrowser Control And Changing Size
20 Aug, 2008 - 04:29 PM
Post #9

LINQ D.I.C.
Group Icon

Joined: 29 May, 2008
Posts: 799



Thanked: 51 times
Dream Kudos: 2175
My Contributions
[quote name='yapper99' date='21 Aug, 2008 - 01:16 AM' post='403964']
[/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...
[/quote]
The private means it can be access from within the form.
Score of Variable Tutorial

vb

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

User is offlineProfile CardPM
+Quote Post

yapper99
RE: Help Please!: Webbrowser Control And Changing Size
20 Aug, 2008 - 05:06 PM
Post #10

New D.I.C Head
*

Joined: 20 Aug, 2008
Posts: 31



vb

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


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

User is offlineProfile CardPM
+Quote Post

AdamSpeight2008
RE: Help Please!: Webbrowser Control And Changing Size
20 Aug, 2008 - 05:14 PM
Post #11

LINQ D.I.C.
Group Icon

Joined: 29 May, 2008
Posts: 799



Thanked: 51 times
Dream Kudos: 2175
My Contributions
QUOTE(yapper99 @ 21 Aug, 2008 - 02:06 AM) *

CODE
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 Aug, 2008 - 05:16 PM
User is offlineProfile CardPM
+Quote Post

yapper99
RE: Help Please!: Webbrowser Control And Changing Size
20 Aug, 2008 - 05:17 PM
Post #12

New D.I.C Head
*

Joined: 20 Aug, 2008
Posts: 31


[/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?
User is offlineProfile CardPM
+Quote Post

2 Pages V  1 2 >
Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 06:16AM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month