Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8023007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:26:09+00:00 2026-06-04T22:26:09+00:00

I am overriding the OnPaint method in my control that I’ve made to draw

  • 0

I am overriding the OnPaint method in my control that I’ve made to draw it directly from an image generated from my own ICan3D.Graphics class. When I save the image (as you can see, that line is commented out) the image is correct. When the form loads, however, it doesn’t display the image as it’s background.

Imports System

Namespace ICan3D

    Public Class RenderSurface
        Inherits Control

        Dim nImg As Graphics

        Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs)
            Dim img As Bitmap = nImg.Visual
            'img.Save("C:\image.png")
            Dim nGraphDis As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(img)
            Dim nPaintEventArgs As New PaintEventArgs(nGraphDis, New Rectangle(0, 0, Width, Height))
            MyBase.OnPaint(nPaintEventArgs)
        End Sub

        Private Sub RenderSurface_Resize(sender As Object, e As System.EventArgs) Handles Me.Resize
            nImg = New Graphics(Width, Height)
        End Sub

    End Class

End Namespace

I’m using VB.net so all .net answers are acceptable 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T22:26:10+00:00Added an answer on June 4, 2026 at 10:26 pm
    Protected Overrides Sub OnPaint(e As PaintEventArgs)
        MyBase.OnPaint(e)
        e.Graphics.DrawImageUnscaled(nImg.Visual, 0, 0, Width, Height)
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When overriding an OnPaint or OnPaintBackground method in an inheritor of System.Windows.Forms.Control, one argument
I'm overriding the draw method of CCLayerColor to draw a border, but the color
I understand overriding a method/function redefines its implementation in the derived class from its
I am overriding the jumpRef method on a drop down control in the design
I have my own classes that represent image data. They have various underlying structure
When overriding a virtual method, I noticed that when I make a mistake in
I'm overriding OnPaint in my control. At times, my control gets invalidated with a
I have a custom control in which I am overriding the following method to
I want to customize ToolStripMenuItem by overriding OnPaint function. This is a MyToolStripMenuItem: public
when overriding the loadView method in UIViewController, should one call [super loadView] in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.