Draw Control like Webbrowser ?!

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
5 posts Page 1 of 1
Contributors
User avatar
PayneStudios
Dedicated Member
Dedicated Member
Posts: 66
Joined: Thu Sep 15, 2011 2:05 pm

Hey Guys,
i would like to know how i can create a Control like Webbrowser that i can import into the Toolbox and drop it to my Form, i want it with white background and i can resize it like the WB Control, how i can draw such control ? with rectangle anyway ?

Greetz PayneStudios
User avatar
M1z23R
VIP - Donator
VIP - Donator
Posts: 622
Joined: Tue Sep 28, 2010 4:55 pm

Re: Draw Control like Webbrowser ?!
M1z23R
Do you want custom web browser? Or just white control in toolbox ?
User avatar
PayneStudios
Dedicated Member
Dedicated Member
Posts: 66
Joined: Thu Sep 15, 2011 2:05 pm

I wonna do a custom browser, but first i need a white resizeable control
User avatar
M1z23R
VIP - Donator
VIP - Donator
Posts: 622
Joined: Tue Sep 28, 2010 4:55 pm

Re: Draw Control like Webbrowser ?!
M1z23R
Under your own class (example Form1) - after "End Class"
Add this:
Code: Select all
Public Class MyWhiteControl
    Inherits Control

    Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
        e.Graphics.FillRectangle(Brushes.White, e.ClipRectangle)
        MyBase.OnPaint(e)
    End Sub
End Class
So, it should look like this, then add control from toolbox ;)
Code: Select all
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        MsgBox("Hello")
    End Sub
End Class

Public Class MyWhiteControl
    Inherits Control

    Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
        e.Graphics.FillRectangle(Brushes.White, e.ClipRectangle)
        MyBase.OnPaint(e)
    End Sub
End Class

User avatar
PayneStudios
Dedicated Member
Dedicated Member
Posts: 66
Joined: Thu Sep 15, 2011 2:05 pm

Thanks, ill try it.
5 posts Page 1 of 1
Return to “Coding Help & Support”