473,383 Members | 1,748 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,383 software developers and data experts.

creating a grid !!

Hello I need major help,
I am trying to make a plane to create a graph, I have been working on
it for a day now and I can't figure it out, the problem is that one
of the drawstring doesn't write the number under the lines and one of
the line, for some reason, it is not proportional !!
Thank you,

------------------------Start User control--------------------------

Imports System.ComponentModel
Imports System.Drawing
Public Class graph

Public Structure Xcord
Public x As Integer
Public xMin As Integer
Public xMax As Integer
End Structure

Public xGridRes As Integer = 1
Public yGridRes As Integer = 1

Dim Points() As PointF

Public y As Integer
Dim xcordnate As Xcord
<Category("Graph"), Browsable(True), Description("Set xScale"),
DefaultValue(5)_
Public Property xScale() As Integer
Get
Return xGridRes
End Get
Set(ByVal value As Integer)
xGridRes = value
End Set
End Property
<Category("Graph"), Browsable(True), Description("Set yScale"),
DefaultValue(5)_
Public Property yScale() As Integer
Get
Return yGridRes
End Get
Set(ByVal value As Integer)
yGridRes = value
End Set
End Property

Private Sub graph_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim xPen As New Pen(Color.Blue)
Dim PrimaryLine As New Pen(Color.Blue, 2)
Dim xcounter As Integer = 0
Dim WinRect As Rectangle = New Rectangle(0, 0, Me.Width - 1,
Me.Height - 1)
Dim Margin As Integer = 25
Dim XLabelCounter As Integer = xGridRes
Dim YLabelCounter As Integer = yGridRes
Dim xRes, yRes As Integer
xRes = Me.Height / xGridRes
yRes = Me.Width / yGridRes
Dim Width As Integer = Me.Width
Dim Height As Integer = Me.Height

e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
'Create Boarder Rect
e.Graphics.DrawRectangle(Pens.Black, WinRect)

'Create Primary lines
e.Graphics.DrawLine(PrimaryLine, Margin, Height - Margin,
Margin, 0)
e.Graphics.DrawLine(PrimaryLine, Margin, Height - Margin,
Width, Height - Margin)

'Create Horizontal lines,
Dim xLabel As Integer

xLabel = (Height - Margin) / XLabelCounter

For xcounter = (Height - Margin) To 0 Step -xRes
xLabel = xLabel - System.Math.Abs(XLabelCounter)
e.Graphics.DrawLine(xPen, Margin, xcounter, Width,
xcounter)
e.Graphics.DrawString(CStr(xLabel), New Font("Verdana", 5),
Brushes.AliceBlue, xcounter + Margin, Height - Margin)
Next

'Create Vertical lines !

xLabel = (Width - Margin) / YLabelCounter
For xcounter = (Width - Margin) To 0 Step -yRes
xLabel = xLabel + System.Math.Abs(YLabelCounter)
e.Graphics.DrawLine(xPen, Margin + xcounter, 0, xcounter +
Margin, Height - Margin)
e.Graphics.DrawString(CStr(xLabel), New Font("Verdana", 5),
Brushes.AliceBlue, 10, xcounter - (Height / 2))
Next

e.Graphics.Flush()

End Sub

Public Sub New()

' This call is required by the Windows Form Designer.
InitializeComponent()

' Add any initialization after the InitializeComponent() call.

End Sub

Protected Overrides Sub Finalize()
MyBase.Finalize()
End Sub
End Class

Sep 20 '06 #1
1 1317
Rohanji,
I suggest you to use this graph control instead:
http://zedgraph.org/wiki/index.php?title=Main_Page

Its one of the best controls ever developed.

Hope it helps.

Sep 20 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: owen | last post by:
Generally speaking, what does it mean when I see a "button" with red text showing this message instead of the control I've dragged onto the web form in Design View.? (But the page works fine at...
4
by: Filippo Pandiani | last post by:
I have a grid that shows the file list from a folder. On the postback, how do I get a Dataset from this grid? Thanks, Filippo.
0
by: Ravi Ambros Wallau | last post by:
Hi: I've created a custom control - a grid that uses Infragistics to display some filters, the grid itself, and some buttons. Well, when using this control directly on WebForm, everything works...
9
by: Niels Jensen | last post by:
Hi All, I'm desperately looking for help regarding the following: I need to make a hexmap in it's own scrollable window on a form, when I say hex map I mean a graphical hexagon surrounded by...
3
by: Tony Johansson | last post by:
Hello!! We are using .NET C# so the product must use this language. The existing controls within .NET is not good enough so I'm looking and evaluating other products. We need a product to...
1
by: ben m | last post by:
Hi all - we've recently switched up to 2005, and I'm having trouble getting the hang of some things, among them, creating a control for the project. Currently, we use a combination of controls on a...
10
by: connyledin | last post by:
Im trying to create a version of the game Wumpus. Mine is called Belzebub. But im STUCK! And its due tuesday 2 maj. Im panicing! Can some one help me?? here is the file:...
3
by: kaczmar2 | last post by:
Hey there, I have a large image in a browser window, and I would like a way to overlay grid lines on top of the image, so a user can show the grid or hide the grid lines. The grid would cover...
0
by: eureka2050 | last post by:
Hi all, I am creating a radar chart containing 2 plots using jpgraph. My code is as follows:- include ("./jpgraph/src/jpgraph.php"); include ("./jpgraph/src/jpgraph_radar.php"); //...
2
by: Mike P | last post by:
I need to create a grid which along the y axis has a user name and along the x axis has a date. Somehow I need to populate the x axis with 6 months worth of dates from the current date, and then...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.