Graphics - How To Clear Form Background

Feb 23, 2012

I am trying to create a simply bouncy ball application in VB net; I am using a timer and the FillEllipse() method to try ad create a new circle at every tick of the timer.

Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim Gr As Graphics = Me.CreateGraphics
Gr.FillEllipse(Brushes.Teal, X, Y, W, H)
CollisionDetect()
X = X + X_Dir
Y = Y + Y_Dir
Gr.Dispose()
End Sub

The result? The form continously draws onto itself, without clearing the last circle. This means that you end up with a 'line' of spheres together.

To clarify:
X is well, the X-Coords
Y is Y- Y-Coords
X_Dir is an integer, it is added to every iteration of the loop so the next time the loop iterates, it'll be at a different location;
Y_Dir is the same but for the Y Coords;
CollisionDetect() Is empty. It is yet to be filled, it will handle the collision with the sides of the forms. W, H are width and height, respectively.

View 1 Replies


ADVERTISEMENT

Use To Clear Graphics On A Form, Picturebox?

Dec 31, 2010

Here are 3 subs I use to clear graphics on a Form, Picturebox, & PaintEventsArgs. I'm overriding DrwClear for each of the objects.

[Code]...

View 7 Replies

Interface And Graphics :: Change Background Image To A Form

Jan 4, 2009

I am trying to put an image selected by the user into the form background. This means that an image from a specified file destination to be set as background.

View 2 Replies

Interface And Graphics :: "stabilize" The Background Image On A Form?

Dec 10, 2009

Is there a way to somehow "stabilize" the background image on a form, because the way it is now, makes it almost unbearable to use background images. I have a transparent panel that has a scroll bar, and when you use the scroll bar, the background image goes all "weird". It also starts flickering when you resize the form, and all in all, it's not that enjoyable to use.

[Code]...

View 9 Replies

Clear All Graphics In Datagridview?

Apr 27, 2010

I use graphics.fillrectangle to draw rectangle in datagrid

and i want remove all rectangle , it's possible ?

View 12 Replies

Drawing Graphics - How To Clear Image In PictureBox

Nov 23, 2011

I have 1 image in picturebox. Now I draw some rectangles. I'm trying clear the image (only rectangles and left the image) without success.

Private Sub btnImageSelection_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImageSelection.Click
Dim intImages As Integer = 0
Dim intImagesLine As Integer = 0
Dim intImagesColune As Integer = 0
picImage.Image = PictureBox1.Image
[Code] .....

The cycles for is for show the rectangules and works fine. but
i.Clear(Color.Blue)
The image is clear but the rectangles are showed and then unshowed.

View 19 Replies

Interface And Graphics :: Appearance Of Pixels Are Not Clear?

Oct 26, 2010

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim cr As New Bitmap(4, 4)

[code]......

View 3 Replies

Picturebox - Clear The Background Double Buffer Before The Flicker

Jun 10, 2011

I have a htpc project that I am working on. The main program loads dlls which are basically other win forms. On each of these forms, including the main program, I use a picturebox (double buffered picturebox) for the background image and then draw everything on it by hand. Whenever I go from the main program to the dll, I get a weird flicker. It looks like it is the previously used double buffer. Is there any way to clear the background double buffer before the flicker?

View 3 Replies

Interface And Graphics :: Groupbox And Transparent Background?

Feb 7, 2009

on the form i have a groupbox with a few textboxes and labels inside of it. Behind the group box i have a picturebox image. I want this image to be seen around the textboxs etc.. through the groupbox

Ive tried changing the background colour in the properties to transparent but you can still see the background colour and so the groupbox covers up the picture.

I want the background of the groupbox to be completely transparent.

View 9 Replies

Interface And Graphics :: Transparent Sprite Background

Aug 27, 2009

I made a game in VB 08 and I have sprites and a background but I need to know how to make the background of the sprites transparent.I'd like to note that I'm using a picture box for my sprite, and the game is animated (I read that those things are relevant).I've read a lot on bitblting but I don't understand it, and when I found a helpful article it mentioned to use the .hdc. This article though was made before the introduction of GDI+ which now makes it harder to obtain said .hdc.

View 11 Replies

Interface And Graphics :: Button Background Gradient Disappears?

Nov 13, 2008

This is VB 2008, under Vista. I can't seem to change the background color of a button without the gradient disappearing.Strangely enough, you can even set the background color to itself and the gradient disappears. How do you keep the gradient but change the color?

Here's an example:

Code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Button1.BackColor = Button1.BackColor ' This should do nothing!

[code]....

View 6 Replies

Interface And Graphics :: Drawing / Painting Imgs To Background.

Feb 9, 2009

Well im just upgrading from VB6 and i was able to paint images to the background of a form. The same method does not seem to work in VB 2008. Is there a way i can draw/paint images to the background of my form?

View 7 Replies

Interface And Graphics :: Moving Buttons And Background Images?

Oct 7, 2009

My app allows the user to set a new button on a tabpage, move it and resize it. They will do this over a background image so the buttons line up with images in the background.Without the background image, the buttons move smoothly and quickly. With the image turned on, the buttons want to move sloooowly and they drag. I made up this code just to show the basic function of what I am trying to accomplish.

Code:
Public Class Form1
Public finalshape As Region

[code].....

View 2 Replies

Interface And Graphics :: Transparent Background In User Control?

Dec 3, 2008

I am attempting to write a simple 11ball style game. It requires images of poolballs overlapping each other. Since the balls will need some internal intelligence I was hoping to create them as usercontrols.I am having trouble gettiing the control's background to be transparent.Setting the background color to (Web) transparent only makes the background clone the form background color.

View 1 Replies

VB Image - Transparent Parts Dont See Form As Background But Marioland As Background?

Feb 18, 2011

Background of form: black

background of char, bombs and shrooms: transparent

picbox behind char, bombs and shrooms is regular (marioland)

How can i fix it so the transparent parts dont see form as background but marioland as background?

View 12 Replies

Interface And Graphics :: Optimizing Forms / Controls Background Images

Aug 1, 2008

I'm developing a VB.Net 2008 application which uses background images (in jpg format) in some forms and controls, but this makes the application to use a lot of ram. My question is how to make it to use the less possible.

View 3 Replies

Interface And Graphics :: Rip Pixel Color Off Of The Background Image Picturebox ( The Level)?

Feb 27, 2009

Ive been working on creating a side scroller game, and the back color of my pictureboxes needs to go. when transparent, it shows through the program and onto whatever is active in your Windows os(usually Visual studios).

I am trying to rip pixel color off of the background image picturebox( the level), and replace parts of the character picture box that show transparency with the level art. there may be poor logic in my code?

Heres my code:

Dim newImage As Bitmap = New Bitmap(PictureBox1.Image)
Dim backImage As Bitmap = New Bitmap(PictureBox2.Image)
Dim ximg As Bitmap = New Bitmap(PictureBox3.Image)

[code]....

not the best idea, but all i get is one color for all the level pixels placed in the new image, which is odd. any poor logic you see in this code that could allow the newImage.setPixel not to be 1 color? when i breakpoint, it is recieving different colors from the backimage.getpixel, but only putting one shade on for setpixel somehow. im not going for an accurate color read from the background yet, just wondering why im getting 1 pixel color for the whole picturebox background when being changed.

View 1 Replies

Assign The ESC Key To Clear Form?

Aug 5, 2009

I looked at another thread to see how to assign the ESC key to clear my form, but it does nothing.

Private Sub frmBookingForm_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown

Select Case e.KeyCode
Case Keys.Escape
InitialiseForm()
End Select
End Sub

Do I need to IMPORT anything before this code works.

View 6 Replies

Clear All Textboxes In A Form?

Nov 29, 2011

I created a Fuction in the module in order to clear all textboxes in a form.

The clear button does work but it still displays an error at the bottom saying :

Expression is of type ........., which is not a collection type.

View 15 Replies

Clear All Textboxes On A Form?

Dec 17, 2011

I am trying to write code to clear all textboxes on a form automatically.

I have entered the following code:

For each ctrl as Control in me. controls

If TypeOf ctrl is TextBox then
ctrl.text = ""
end if
Next

The form has various controls on it, including textboxes, buttons, and others. When I run the above code 'ctrl' only seems to find buttons but not textboxes.

View 6 Replies

Clear Textbox On Form?

Apr 22, 2009

How to clear textbox if the value equal zero i have several textbox's with currency look at the picture i am posting you will see the price of 2.99 then under neath for other box'shas this $0.00

View 9 Replies

How To Clear All Textboxes On Form

Nov 14, 2011

I tried this code but it is throwing error.
Private Sub ClearText
Dim ctl As Control
' Clear all the TextBoxes on the form.
For Each ctl In Controls
If TypeOf ctl Is TextArea Then ctl.Text = ""
Next
End Sub

View 1 Replies

Way To Clear All Textboxes In Form

May 23, 2011

I was wondering if there was a simpler way to clear all the textboxes in a form instead of having to do. [code]

View 4 Replies

Interface And Graphics :: Adding A A Form As A Child Form To A Third Part Window

Mar 24, 2011

As Autodesk is going to discontinue VBA for their Inventor product in the near future I have been looking at other ways to run VB.NET in Inventor. To date it doesn't look like VSTA will be the replacement. Automation from an External VB.NET app is certainly possible, but leaves something to be desired for speed and integration. Compiled Add Ins are the Cadillac of choice but can be a royal pain to debug and develop. Autodesk now provides a lightweight VB.NET script interface called iLogic. It's main purpose is to allow extreme customization of Solid Modeling parts. The code actually resides inside the Part Model file.

[Code]...

View 7 Replies

Create A CLEAR BUTTON Loop To Clear All Textboxes?

Dec 13, 2011

this is currently my code to clear my 5 textboxes

Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click

TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
End Sub

View 16 Replies

Clear All Checkboxes At Form Load?

Feb 4, 2009

I have a pile of checkboxes on one particular form and would like to clear them all at the form load rather that saying chk1.Checked = False for all of them.

Here is the code I was trying to use but 'checked' is not a member of Systems.Windows.Forms.Controls.[code]....

View 2 Replies

Clear All Controls Upon Form Exit?

Feb 3, 2011

i need to clear all the run time controls that were added upon form load when i close the form.

View 7 Replies

Clear Or Reset Form BackColor?

Oct 19, 2010

How do I clear/reset the BackColor of a windows application form? For instance, I have a set of radio buttons, each one changes the color of the background form color, when i reset the radio buttons i would also like to reset the color of the form back to it's original state?

View 2 Replies

Code To Clear All Textboxes In A Form?

Jun 21, 2010

I am trying to find a code to clear all text boxes in a form. I am using VB8 Here is the code I found but I get an error telling me I need a comma between two arguments

Private Sub btnclearall_Click
Dim ctl As New Control
For Each ctl In Me.Controls

[code]....

View 4 Replies

Creating Clear Form Functions?

Mar 2, 2010

I am trying to create a function to clear my form. The code is as follows:

Private Sub resetForm()
'Set an integer to loop through the controls
Dim x As Integer

[code]....

it works when I set the type of control as textbox but when I try to do the same thing with radioButton and make it's checked proporty = to false I get checked is not a member of 'system.windows.forms.control'

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved