|
-
Jul 15th, 2004, 02:36 PM
#1
Thread Starter
New Member
Form gets redrawn
Or atleast, that's what I think.
I have an application upgraded from VB6 to VB.Net. I am using the following code to call the method to open an xml file and draw the graph based on the file contents.
Public Sub mnuFileOpen_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles mnuFileOpen.Click
FileOpen_Renamed()
End Sub
But just after executing the end sub, whatever i have drwn gets erased. And when I lok through the debugger, th step goes nowhere.
I am new to VS.Net. Any help would be appreciated.
Thanks,
Smitha.
-
Jul 15th, 2004, 02:43 PM
#2
Sleep mode
Put your drawing code in the OnPaint event .
-
Jul 15th, 2004, 03:10 PM
#3
Thread Starter
New Member
It didn't help. Thanks for the suggestion though.
-
Jul 15th, 2004, 06:50 PM
#4
Sleep mode
Then your problem is not with form redraw ? Show some code to help others figure out what's your problem !
-
Jul 16th, 2004, 12:59 AM
#5
Thread Starter
New Member
Hello Pirate,
Thanks for taking your time to answer.
When I put the code to call tge method draw the graph in On Paint event, it goes into an infinite loop, it just draws and redraws the same thing again and again.
Could you please tell me what I am doing wrong?
Thanks
Smitha.
-
Jul 16th, 2004, 04:45 AM
#6
Junior Member
Problem not with events
There are few new things in .net in terms of GDI. I hope that your code is not using the line, circle objects which are obsolete in VB.net.
In previous threads you have tried changing the events but I think the problem lies in the function where you draw.
Can you show us the code so that we get a better picture? It is essential as the Graphics objects have gone through major changes in vb.net.
Give me a place to stand and I will move the Earth 
-
Jul 16th, 2004, 05:31 AM
#7
Sleep mode
Another way to pertain your drawings is to save them in a image . Post some code ...
-
Jul 16th, 2004, 11:11 AM
#8
Thread Starter
New Member
Here is the sample code:
Public Const cEDITGRID As Short = 500
If mnuModeEdit.Checked Then DrawGrid(cEDITGRID, cEDITGRID)
endif
Public Sub DrawGrid(ByRef CellH As Short, ByRef CellW As Short, Optional ByRef XOffset As Short = 0, Optional ByRef YOffset As Short = 0)
Dim Index As Integer
Dim OldColor, OldWidth As Integer
Dim yVal As Integer
Dim XVal As Integer
Dim yVal1 As Integer
Dim XVal1 As Integer
'Draw Grid
With mForm
OldColor = System.Drawing.ColorTranslator.ToOle(.ForeColor)
OldWidth = grayPen.Width
g = mForm.CreateGraphics()
grayPen.Width = 1 : .ForeColor = System.Drawing.ColorTranslator.FromOle(&H8000000C)
For Index = XOffset To VB6.PixelsToTwipsX(.Width) Step CellW
yVal = VB6.PixelsToTwipsY(.Height) - 500
XVal = VB6.TwipsToPixelsX(Index)
g.DrawLine(grayPen, XVal, YOffset, XVal, yVal)
Next
For Index = YOffset To VB6.PixelsToTwipsY(.Height) - CellH Step CellH
yVal1 = VB6.PixelsToTwipsX(.Width)
XVal1 = VB6.TwipsToPixelsY(Index)
g.DrawLine(grayPen, 0, XVal1, yVal1, XVal1)
Next
grayPen.Width = OldWidth : .ForeColor = System.Drawing.ColorTranslator.FromOle(OldColor)
End With
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|