473,385 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

draw a rectangle

i have to click a button and draw a rectangle in vb.net form like wise drawing a rectangle in painbrush..give me sample coding
Mar 7 '08 #1
2 852
Ok your button isn't included here sorry, it was a bit complex to me(i'm a bit noobie here) so you can figure out yourself anothe way or make it with the button. anyway, here's the code to draw the rect:

Public Class Form1

Dim r As New Rectangle(100, 100, 100, 50) 'the rectangle to fill

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint

Dim g As Graphics = e.Graphics 'graphics class
g.FillRectangle(Brushes.Black, r) 'draw it

End Sub
End Class

Learned anything? ok, that's it for now. if you want i post more gdi+ help so only ask me.
Mar 12 '08 #2
GIVE ME SAMPLE CODE:
sir,thank u sir,but i want to draw rectangle freehand in runtime sir....in my form i have one button name rectangle...i want to click that button and draw rectangle freehand in runtime.....
sorry for inconvenience sir.
thnak u sir..
Mar 13 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: dunkonu | last post by:
I am new to VB.net, can anybody help me how to create a form that ask user to enter the "WIDTH" and "HEIGHT" and draw a box display in the textbox? thanks
3
by: Richard | last post by:
I have a requirement to put a GDI style circle or rectangle border around the selected row of a datagrid/ It will overlap into the row above and below the selected row. Doing this in a the OnPaint...
1
by: Praveen | last post by:
Hello, I have a web page which will display the map of a city/place. I have a toolbar which contains 'zoom in' and 'zoom out' buttons. When the user clicks on zoom in/zoom out button, he should...
3
by: Colin McGuire | last post by:
Hi there. I have written a small procedure to draw various shapes on things. A bit of it is shown below. Private Sub drawShape(ByVal shapeType As Integer, ByRef g As Graphics) Select Case...
1
by: Rob Richardson | last post by:
Greetings! I am creating a form that will contain information that will eventually be on a label. The label has a 2-column table with lines separating the cells. I want my form to resemble the...
3
by: Tom | last post by:
Hi Hi i am trying to draw on top of a button on a standard toolbar. All i want to do is draw a small rectangle on the button to represent the selected color. I have tried the folowing code in...
7
by: Mark Ingram | last post by:
Hi, how can i draw a rounded rectange, with a border within a specified area? i.e. if i have a Rectangle with width and height of 100, how can i draw a rectange with 2 pixel border inside of the...
2
by: Andy Chen | last post by:
Hi, Now I can get the rectangle to draw, but it seems the rectangle is not visible. The following code is used to draw the rectangle. Hope someone can help. Thanks very much! SolidBrush brush...
1
by: Jeff Waskiewicz | last post by:
Hello All, I'm trying to solve a nagging problem. The goal is to draw a rectangle over the top of all the other controls on a form. Specifically, over a ChartFX control. The user would draw...
1
by: kummu4help | last post by:
hi, i want to draw rectangle based on mousedrag event. if user dragging the mouse, then the rectangle on the applet should increase or decrease basing on current mouse coordinates. i have the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.