Use A Picture Box To Draw The Lines?
Jun 12, 2011Iam doing a sample project for school and i CHOSE Tic Tac toe. sample program of it becuase i have no idea where to start. And do I use a picture box to draw the lines?
View 1 RepliesIam doing a sample project for school and i CHOSE Tic Tac toe. sample program of it becuase i have no idea where to start. And do I use a picture box to draw the lines?
View 1 RepliesI want to draw string in multiple lines and and I want to know how many lines given string will take. I am using following method.
[Code]...
I'm making the transition from VB6 to VB2008 and I'm having difficulty finding the equivalent to[code]...
It seems in VB2008 I can only use pens inside a picturebox1_onpaint() subroutine, I can't tell a picturebox what to do from a button_click subroutine or form_load subroutine first and then send the results to a picturebox. I have no control over when the graphics are drawn and from which subroutine. How do I solve this in VB2008 ?
I have a simple picturebox, line drawing procedure (call it "DrawTheLine"), which fires ok when I call it from a command button. But when I try to call it from the boot form_load procedure it doesn't work; no lines draw. No errors are raised.
Things I've thought of are:
1. The form_load procedure is not done creating all of the controls on the form, so it can't work with them yet. Doesn't make sense because my drawing call is the last thing in the form_load procedure, and it executes, but the picturebox does not show the lines.
2. Tried Application.DoEvents, but no go.
3. Tried using picturebox.invalidate to force a paint event and "called" the drawing procedure that way, with the appropriate arguments. Again, the procedure "DrawTheLine" fires, but no lines draw to the picturebox.
I have the following form:I want to join the boxes so that it looks like this: would rather create the lines on the userform manually but I do not think there is a way to do it. I've tried the following code but I cannot see the line:
Private Sub DrawLine(ByVal X_From As Integer, ByVal Y_From As Integer, ByVal X_To As Integer, ByVal Y_To As Integer, _
ByVal Line_Width As Integer, ByVal Line_Colour As System.Drawing.Color)
[code]....
I need to draw dashed lines. I use this code:
Dim MyPen As Pen = New Pen(Color.Black, MyWidth) With {.DashStyle = Drawing2D.DashStyle.Dash}
MyGraphics.DrawLines(MyPen , MyDots.ToArray)
But since the distance between successive lines it too short, the dashes start each one too near to the last. It causes a continuous black line
How would I do this? I want my Program to draw 2 lines in the center of the screen.
View 3 RepliesI can draw one line by mouse moving on a form, but i used cls function to clear screen when move mouse (otherwise it wont show single line when move mouse), so i cudnot draw next line with out clearing previously drawn line, kindly help how to solve this problm
[Code]...
I am making a drawing application (Graphics class), with a highlight pen and a calligraphy tool. But the pen tip should not rotate according to the line direction. I have tried the CustomLineCap, but still not working.
View 3 RepliesHow to draw lines inside the circle. I mean a circle with n-number of lines within in it.
View 7 RepliesFirstly I am using Vb 2008 Express Edition.I have the following code:
Code:
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e _
As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
Dim x1 As Integer = 0
Dim x2 As Integer = 50
[code]....
When I run the above code it works , no problem. But I want to trigger it only on my Button_click event.
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
I don't know how to call the PictureBox1_Paint into my Button1_Click
i want to "draw" zebra lines in my form [code] ican import background image, but I prefer code :)
View 1 RepliesThe image editor toolbar is not active. I would like to draw lines and shapes on a form.
View 1 RepliesI need to draw lines, in one VB form. Like paint, I need the tool brush, and design some lines and curves in a Vb form. How can I do this? I don't know where to start.
View 3 RepliesHow do I draw lines using DirectX? (on my form)
View 1 RepliesI'm trying to draw a grid using vertical and horizontal lines.Both For..To statements work fine when one of them is commented out otherwise, they won't work together. At run, only the first For..To statement is executed.[code]
View 6 RepliesI have some lines drawn in many different directions (2D y 3D enviroments). Is there any way to draw text oriented along the direction of each of these lines? It was an easy task in former versions of Visual Basic, but now it looks like a very tough -almost impossible- mission.
View 4 RepliesI'm trying to do something that is turning out to be out of my league at the moment. I need to draw geometric figures. These geometric figures have all the coordinates of their corners. Say I have a trapezoid, and I would want to draw it. The drawing would be done in a picturebox or a panel or a groupbox (some part of the form where only the geometric figure will be).
I saw the method on how to do that Here and that's exactly what I'm trying to achieve, but there it's drawn on a newly created form, and I need it in a picbox, panel or groupbox as I mentioned above. I also need the drawn figure to be at the center of the picbox/panel/groupbox.
The coordinates of the lines should be like (xa.text,ya.text) to (xa.text - xb.text, ya.text + yb.text) if I'm not wrong for the first line of the geometric figure and so on.
How come this doesn't work...
Private Sub ColorKeyForm_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
'Draws diagonal line of dot and dash on form
[Code]....
... the top part draws a line on the form but the second part does nothing. The picColorKey is a picture box on the form.
I need to draw a line on a series of pictures: I have decompiled a movie file to 1200 pictures. I also have 1200 samples of vector data (coordinates of the line: beginning point, ending point , size of vector (length) and direction (angle)... anything). With these data I want for each corresponding picture to draw a line corresponding to this vector data for instance: picture 550 needs to get a line drawn from point (5,95) ... these are (x,y) coordinates. in direction of 5 degrees from a vertical line and length 55. Visual Basic do that? I understand there will be some work in locating the origin of the x,y coordinate system and telling the program what 'size 1' means...
View 4 RepliesI am building a 2D game where the user is a circle() and the enemies are rectangles coming at him. However, my problem is that when I placed a very nice picture of space I found on the internet, the screen draws whatever it has to underneath this image. Everything works,I can still see my lives going down when something collides into me - except the fact it is all covered up by this picture.
[Code]....
I am building a 2D game where the user is a circle(:P) and the enemies are rectangles coming at him. However, my problem is that when I placed a very nice picture of space I found on the internet, the screen draws whatever it has to underneath this image. Everything works,I can still see my lives going down when something collides into me - except the fact it is all covered up by this picture. How Do I Draw everything ON Top of this - (I tried using the 'Send To Back' Command)
EDIT: The form draws everything through a timer, and the user controls his character through keys.In the mybase.load procedure:
PicBackGround.Dock = DockStyle.Fill
PicBackGround is the picture box with the image.In the paint procedure:
e.Graphics.Clear(Color.Black)
e.Graphics.FillEllipse(Brushes.Orange, Player)
[code]....
Player is a rectangle declared right at the top, Dim Player As New Rectangle(0, 0, 50, 50); There is then the array Objects, which stores all the data about the enemies coming at the player, Current_Projectiles is simply an array to store data about rectangles(bullets) that the player fires.
How do I draw lines like these ones at top (underneath the white box) and bottom (above the buttons) - preferably in the GUI?
View 6 RepliesI think we can just draw an image that resemble the grid using this article : drawing in a datagridview Currently creating a way to make the image drawn in tile mode. Each time I develop a datacentric application using VB.NET regardless of how much the data displayed in the datagrid, I always want the grid to display full row of empty data, not just blank panel. Can we achieve this using VB.NET design time property? And also, we must not trigger the display of vertical scrollbar this way..
View 1 RepliesI am currently using Visual Basic 2008 Express Edition.I want to make a program that will draw 700 random lines on it initially. I tried my code but the lines only appear in the same way such as straight line and diagonal line. Here's my code:
Public Class Form1
Private Sub Form1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
[Code].....
I've got a project where I want to be able to display a world map and draw lines between cities.I've looked at using a web browser with google maps but don't want it to have to be used while "online"
I've looked and longitude and latitude and converting these to UTM co-ordinates but i'm lost for how to place these on world map programaticly.I have a full list of all cities used in my program and have a list of their latitude and longitude co-ordinates because i need to work out thier distance apart which I have already done the code for.
I have started to work some more on my 'shape editor'. If you're not familiar with it,ust imagine the Visual Studio form designer: a 'canvas' (the form) with a bunch of 'shapes' (the controls) that can be selected, moved, resized, etc. I have just finished implementing snapping between shapes and the canvas boundaries. But now I am having some slight issues with painting the snap lines.Just FYI: this is what I mean by snap lines:The blue lines that indicate that the 'buttons' are snapped to each other, and a purple line indicating that button1 is snapped to the boundary.
My shape editor is based loosely on jmcilhinney's 'manipulating GDI+ drawings' codebank entry, and a central idea in that post is to only draw what is necessary. In other words, when I move a shape I could re-draw the entire canvas, but it is much faster and smoother to only re-draw the old and the new location of the shape. Since nothing else has changed, I don't need to draw the rest. So, I simply invalidate the old bounds and the new bounds, and even with a lot of shapes all moving simultaneously it still feels very smooth.
I want to draw a line on an image in a picture box. How do I do? The picture box is placed as the only item in a standard form. The following doesn't work:Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
Dim TestLine As System.Drawing.Graphics
TestLine = PictureBox1.CreateGraphics
Dim TestPen As New System.Drawing.Pen(System.Drawing.Color.Red)
TestLine.DrawLine(TestPen, 10, 10, 50, 50)
TestPen.Dispose()
End Sub
The corresponding method for the paint event works fine in a panel, but the picture box doesn't seem to support it. What am I doing wrong?
I want to Draw an Rectangle on a PictureBox and after that I must be able to move this Rectangle around. I have made now that I can draw a Rectangle on a Picturebox via MouseDown and MouseMove Events, but I dont know how to Move the Rectangle.
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
Try
If e.Button = MouseButtons.Left Then
cropX = e.X
cropY = e.Y
[Code] .....
i am making application for image cropping. where in this application i want to draw transparent rectangle on picture box.eg> you must have uploaded photo on orkut , when u upload the photo if photo is too big croping windows comes up and tranparent rectangle with resizable appears on image.similarly i want resizable rectangle on my picturebox where user can resize the rectangle and then user press crop button it crops off that much part.my question
1) how to draw transparent rectangle on picturebox
2) how to resize it.