|
I've got what I'm sure is a trivial question. I want to draw a graph in Visual Basic on an object on a form.
I would like to know what is the best object to use. I tried a panel as my first choice but in the properties I couldn't find something which would override the OnDraw and let me draw my own things.
There must be a standard way to do this, but I don't use VB much so I'm not familiar with it.
Thanks,
Ilan
|
|
|
|
|
A Panel can be used, or a PictureBox. Either is good. You override the Paint method of the control you use. For example:
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles PictureBox1.Paint
Dim g As Graphics = e.Graphics
' do your painting for the control
End Sub
Another way to do it, would be to draw to a Bitmap image and just set the PictureBox Image or Panel BackgroundImage property to the Bitmap you've drawn on.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I was about to ask you where to put that private sub, when I looked again at the properties and again found nothing. Then I double clicked on the pane and voila, the paint proceedure appeared!
Sometimes things are so easy that I miss the truely obvious.
Your Dim g as graphics would have been my next question, but you answered it. My only mistake was to put a semicolon at the end of the statement (habit is a hard thing to break).
Thanks,
Ilan
|
|
|
|
|
If you switch to code view, just above the window you'll find two dropdown boxes next to each other. Pick the control you want to handle an event for in the left side box, then pick the event/method/property you want to handle/override in the right side box. This will automatically create an empty event handler in your code, complete with the correct event header.
You can also do the same thing with the Property window. Near the top of that window there is a small button with a little yellow lightning bolt in it. If it doesn't show up, click on the control you want in the designer, or pick it from the dropdown list just above the Properties window. When you click on that lightning bolt, the Properties window will switch to showing all the events exposed by that control. Find the event you want, then double-click in the white box to it's right and it'll create an empty event handler for you.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Great! I found it in the code view. Now that I know where it exists I'm in business.
I don't see the lighting in the properties page. I'm used to using it all the time in c++, but I don't see it in Visual Basic. In fact, since I'm used to it in c++, this was the place I was looking.
Never mind, so long as I know it exists in the code view, I'm in business. It does the dirty work of building the proper templates so they are right the first time around.
Thanks again,
Ilan
|
|
|
|
|
|
I wanted to reinvent the wheel only enough to learn how to do something should I have to do so. Thus I tried Dave's suggestion to get a feel for things.
Enough reinventing the wheel, and I will have a longer look at the ZedGraph. Presently it seems I have NET 1.1 so I can't use the latest version 5.0. (I have Visual Studio 2003 and don't want to update just for this.)
Thanks,
Ilan
|
|
|
|
|
As you are most probably already aware, but I wasn't certain so I thought I would just say, you can download version 4.3.5 from the SourceForge project site[^] which works with .NET 1.1.
|
|
|
|
|
Alex,
I am really impressed. I want to thank you for pointing out the code to me. I was just thinking of making a simple graph with some text and wanted to avoid reinventing the wheel.
This isn't a wheel but the whole automobile! I see I can use it in c++, so I'll use it there as well.
My trivial question in Visual Basic turned out to a super answer.
Ilan
|
|
|
|
|
Hi guys,
I'm currently working on how to lock or at least hide a certain folder,
below are the codes that i'm tryin to use...
renameFileName = (InputBox("Folder Name:", "Unlock", "Cycle #"))
System.IO.Directory.Move(path & "\.{20D04FE0-3AEA-1069-A2D8-08002B30309D}", path & "\" & renameFileName)
thing is, its working on my local folders, but when i used it to a folder on a mapped drive its just renaming it, and i still can access the folder...
if you guys got another approach on how to do this...
tnx in advance.
-::maximus::-
|
|
|
|
|
That won't work on network drives. The only way to hide folders on a network is using Access Control Lists and assign the appropriate permissions to users/groups. Exactly how this is done depends on your network O/S.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
|
Uhh, you do realize that link is for the Team Foundation Server Source Control, right?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Guys,
Do you know of any forum (publication) where I can get some information on how to I can incorporate an exe or dll in custon setup in VB.NET. I want to include a form that should prompt for User_ID and Password during setup. Most of the examples I have seen are in C#.
Regards,
manv
|
|
|
|
|
Those examples are easily convertable to VB.NET. If you look at any example code on MSDN, there are usually code samples in both VB.NET and C#. You couldn't ask for a better Rosetta stone to show you how to translate between the two.
If you want, you can also copy/paste code snippets into an on-line translator, like this one[^]. The only problem with using these is that not one of them can do a perfect job of translating the code. They can come close though...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Well, am comfortable of course with conversions from C# to VB. However may be I havent found a good example. Do you know of any example using a dll or exe in custom action, you can just give me the link.
manv
|
|
|
|
|
I don't know of any examples. I can't release what I've done to you because I don't use Visual Studio's Setup projects. I'm using Wise for Windows Installer.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I'd like to know how to detect an USB Device if it's plugged in, so if the user for example, plugs his MP3-player in the program pops up, and shows the drive letter of the Usb device. Anyone?
--Zaegra--
|
|
|
|
|
There's just WAY too much information to cover on how to do USB in a forum environment. You can learn a lot, though, from checking out the article and code samples in this[^].
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
I am using grid in my window form.I have 2 problem.
1)how to save image in sql database
2)How to show image in grid
I hope you help me.
Regards,
Nagraj
|
|
|
|
|
if i'm having the JobID of current printing document
how can i get the Printer name which is printing that?
code pls
"You can do any thing you set to your mind" - theGhost_k8
|
|
|
|
|
How are you getting the JobId? The job is stored in the queue of the printer printing it. There is no "one" job that is the current job, because you can have multiple printers, each printing it's own "current job" at the same time.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
well i;m actually using printing component that generates event.
Problem with it is i've created 2 saperate app. with diff. printer names(same Component)
thus i'm getting the jobid. but prob. is that compo. raises event in both proj.. so i want to identify printer name(printer_app1 or Printer_app2) using jobid
if doc is printed using printer_app1 then
exit from app2's event and conti. app1's event and vice versa..
well i've got some ways out there that includes WMI, API(get job) etc..
but in that i'm not able to get rid of the error
"An unhandled exception of type 'System.ExecutionEngineException' occurred in system.management.dll"
and i'm not able to retrive details from api... i've searched through net explaining uses and etc but i cant complete that using api...
http://www.merrioncomputing.com/Programming/PrintJob.htm
well i'd aspecting if u can post some code ...
--thanks
"You can do any thing you set to your mind" - theGhost_k8
|
|
|
|
|
Kedar V wrote: but prob. is that compo. raises event in both proj
Of course it is! A print job was started; it doesn't matter which app started it. It'll raise that event in your apps if Notepad printed something.
Kedar V wrote: WMI, API(get job) etc.. but in that i'm not able to get rid of the error
"An unhandled exception of type 'System.ExecutionEngineException' occurred in system.management.dll"
What's the code you're using to get the WMI data for this job?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Dim oq As System.Management.ObjectQuery = New System.Management.ObjectQuery("SELECT * FROM Win32_PrintJob")
Dim query1 As ManagementObjectSearcher = New ManagementObjectSearcher("SELECT * FROM Win32_PrintJob")
Dim queryCollection1 As ManagementObjectCollection = query1.Get()
For Each mo As ManagementObject In queryCollection1
MsgBox(mo.Item("Document").ToString())
"You can do any thing you set to your mind" - theGhost_k8
|
|
|
|