|
Great! And your question is?
RageInTheMachine9532
|
|
|
|
|
|
First, I have to question why you would want to do this? There are many controls already out there that handle chart drawing of any imaginable type. I just don't see the point in reinventing the wheel...?
But if you must, you could use a PicBox or draw directly on the Form itself. I would suggest writing this as a control using a PicBox so it can be reused in other projects. First, you have to work out a method of keeping track of data. This is going to depend on the type of data your working with. Then, you calculate the scaling for your data, then calculate the size of your chart and its scaling in the PicBox. Your also going to have to calculate positions for labels and font scaling.
When you have all that, you have to write your code to paint the chart in the Paint event of your control. Get a Graphics object for the PicBox by using the CreateGraphics method of the PicBox. Then you can use the Graphics objects methods to draw what your chart is going to look like.
Just as an example of drawing using the Graphics object, this is a little snippet of code from a goofy little control project I worked on a while back:
Private Sub threadDrawingLines()
Dim x As Integer
Dim objPen As New Pen(Color.Blue)
Dim grPicBox As Graphics = PictureBox1.CreateGraphics
Try
While (pNumberOfLines > 0)
For x = 1 To pNumberOfLines
grPicBox.DrawLine(objPen, Lines(x, 1), Lines(x, 2))
Next
UpdatePositions()
Thread.Sleep(pSleepTime)
End While
Catch ex As ThreadAbortException
grPicBox = Nothing
objPen = Nothing
End Try
End Sub
RageInTheMachine9532
|
|
|
|
|
tahkns for the help. Its mean that what i was doing is write i am making my own charts . The reason why , which you have asked , The answer is that i have devoloped the clases for printing so what ever i draw on the panel will go as an output to the printer. And the project on which i am working is a document formatter which is connected to some data sourse and the charting facility like Acces is a main module for the project. so Thats why i am doing all my own.
|
|
|
|
|
i have a picbox which user will draw different kind of drawing on the picbox,
i trying to find a way which when user draw the first drawing, i save the content of the picbox to a place, after user define the second drawing, i will copy the saved content back to the picbox to attach to the second drawing, so all the drawing will retained... someone suggested me use double buffering on the picbox to save the picbox into a bitmap file, but i am really a beginner in VB.Net, can someone provide me about the coding of double buffering on the picbox?? thanks very much for any help!!!
|
|
|
|
|
sounds like RageInTheMachine9532's q . do this so u retain both images - no need 2 save 1st image:
private sub picbox_paint(e....) .... handles paint
if drawmode = 1 then 'first time user draws
e.graphic.drawrWW() 'this is the first drawing
picbox.invalide() 'refresh picbox
end if
if drawmode = 2 then 'this means user chose draws anaa shape
e.graphic.drawWW() 'this is the first drawing
e.graphic.drawXX() 'this is second drawing
picbox.invalide() 'refresh picbox
end if
end sub
|
|
|
|
|
Hi i am using RS232 class which is new concept in .NET.i am using the latest RS232 class.
but i am not able to retrieve any data,i have used "Inputstream" property of Comm.even though it shows some error,if any one know the exact method,please do let me know
|
|
|
|
|
i have form1 and form2, form1 has a picturebox which i already drew something on it(e.g. rectangle)
i active form2 to chose another shape to add below the rect, after form2 closed, the new shape should be added below the rect and the rect should be remained in its original position on the picbox(something like drawing flowchart).i used picbox_Paint event handler to draw the rect, but when i added new shape using the same Paint handler the rect is gone??!is there anyway to fix this problem?? what i try to find is the way to keep the drawing on the picbox remained till the application is closed... below is my current coding summary
private sub picbox_paint(e....) .... handles paint
if drawmode = 1 then
e.graphic.drawrect() 'this is the first drawing
picbox.invalide() 'refresh picbox
end if
if drawmode = 2 then 'this means user chose another shape from form2
e.graphic.drawXX() 'this is second drawing
picbox.invalide() 'refresh picbox
end if
end sub
|
|
|
|
|
You have to rewrite your paint handler to paint BOTH rectangles. WHat your doing in your handler is telling the PicBox to invalidate it's entire client area. THen your handling the paint event yourself, but never redrawing the first rectangle. You have to modify your code to keep track of EVERYTHING that you want repainted in the picbox, then redraw it all yourself since your handling the paint event yourself.
RageInTheMachine9532
|
|
|
|
|
Guess RageInTheMachine9532 is saying this so u retain both images:
private sub picbox_paint(e....) .... handles paint
if drawmode = 1 then
e.graphic.drawrect() 'this is the first drawing
picbox.invalide() 'refresh picbox
end if
if drawmode = 2 then 'this means user chose another shape from form2
e.graphic.drawrect() 'this is the first drawing
e.graphic.drawXX() 'this is second drawing
picbox.invalide() 'refresh picbox
end if
end sub
|
|
|
|
|
thanks for RageInTheMachine9532 and kamush help!!
but wat i actually drawing is a flowchart, which mean each time user define a new drawmode or shape, the coding is very long and complicated and the label of the drawing will be different...if i change the code to wat u suggested me, my coding will be tremedous long and complicated!!
i dunno whether u understand me or not(my english is pretty poor)...
anyway thanks for ur help...i post a new question about this problem, if u have new idea plz reply there ok? thanks very much!!
|
|
|
|
|
Hi all
I need some ideas for a project I am working on. I have data on one server that I can link to a MS Access dB using a driver provided by the application owner. I want to copy those linked tables to a .CSV file, which is not a problem in Access....but I need to write a procedure in VB that will be scheduled to run automatically on a different server than my data (and the dba doesn't want to install Access on this server).
I don't know vb well enough to know how to approach this. should I use activeX components or code that reads each table and writes to a .csv?
any suggestions are welcomed.
tia
ca
|
|
|
|
|
Hi newbie,
The app data and MS Access dB can b on one server while a vb acxtiveX component (with procedure scheduled to run automatically ) is on the other. they link remotely. i don't c the probo here..
|
|
|
|
|
Using Excel, I inserted a text file to the sheet, and pasted it as an OLEObject (from the Excel menu "insert" then "object" and choose text file).
I want to read the file context (using Excel VB macro), but I don't know how to access and open this OLEObject (whitch contains the file).
|
|
|
|
|
I m new to VB 6 programming and i have encountered some problems.
I have to load a text file into the program and search through the file to find a keyword 'entities'. When the program reaches the keyword, it has load some values at different lines of this text file into the program array.
This is one of the possible algorithm i have thought of:
1.Select the file
2.Search through the file for keyword 'Entities'
3.Load the values into the array.
However, i am stuck in step 2. Could anyone of you please give me some suggestions on how to complete step 2 and step 3??
Thankyou so much.
Esther
|
|
|
|
|
ESJY, b sure include a button (Command1) on your form. not sure wat step 3 is about..
Option Explicit
Option Base 1 '//start array at index 1
Option Compare Text
Private vArray() As Variant '//array of variants - can b specified
Private Sub Command1_Click()
Dim vVariable1 As Variant
'Dim iFile As Integer
Dim i As Integer
Open "c:\sample.txt" For Input As #1 'iFile
While Not EOF(1)
Input #1, vVariable1
If (vVariable1 Like "*Entities*") Then
i = i + 1
ReDim Preserve vArray(i) As Variant
vArray(i) = vVariable1
MsgBox vArray(i)
End If
Wend
Close #1 'iFile
End Sub
|
|
|
|
|
thanks kamush, that really helps...
how many variable can be stored in the array?? because the file to be loaded is a very large file and therefore there is quite a number of variables to be read into the array.
|
|
|
|
|
Hi ESJY,
an array is jus memory space, so it can take quite alot but slows down your app, right? wat do u want the array for? u could read 5 lines after the keyword n display it (or whatever u wanna do). jus depends on wat u want Esther..
While Not EOF(1)
Line Input #1, vVariable1 '//reads whole line
If (vVariable1 Like "*Entities*") Then
i = i + 1
if (i=5) then
i=1
ReDim vArray(i) As Variant '//reset array wit 1 item..
else
ReDim Preserve vArray(i) As Variant
end if
vArray(i) = vVariable1
ListBox1.AddItem vArray(i)
End If
Wend
|
|
|
|
|
oh... Thanks a lot... in fact i need an array to store information to be excuted by a machine. Anyway, thanks a lot for ur help. Merry Christmas and HAppy New Year
|
|
|
|
|
I need to authenticate a user in a VB.NET Windows Forms app by validating a username/password against the domain login. All the samples I've been able to find have dealt with everything *around* the validation, and not the validation itself. I'm assuming that NTLM is the authentication method, and I should be able to use ADSI to do the validation, but I don't know how, and can't find an example. Any pointers?
Thanks,
Vincent
|
|
|
|
|
If the user is already logged in, why would you need to re-authenticate?
--Colin Mackay--
"In the confrontation between the stream and the rock, the stream always wins - not through strength but perseverance." (H. Jackson Brown)
Enumerators in .NET: See how to customise foreach loops with C#
|
|
|
|
|
The applications involve check processing, and they want to force authentication at start-up in case someone walks away from their machine without logging out or locking it. I think there are better ways to address this situation, but they insist. And I suppose that situational/momentary authentication could be useful for "manager override" kinds of functions.
Does that make sense?
--Vincent
|
|
|
|
|
There are other electronic signature requirements which this also needs to be performed.
Does anyone have a VB6 solution to validating domain user/password?
|
|
|
|
|
as topic, if i have form1 and form2, form1 active form2 by using form2.show
how to make form2 on the top of form1 which make user cannot click on form1?
i used form2.topmost = True, although form2 is on the top of form1 but user still can click on form1
which make form1 become the active form and form2 become inactive
wat i require is user must close form2 first b4 they can clickon form1
how am i going to do that?anyone can help?
any help is greatly appreciated....
|
|
|
|
|
when you are showing the form2 just say form2.show vbmodal.
then the user cannot click form1
|
|
|
|