|
One way to do it is to loop through the datagridview and then call the System.Diagnostics.Process
Something like:
dim p as System.Diagnostics.Process
p.StartInfo.Verb = "print"
p.StartInfo.FileName = "putthefilenamehere"
p.StartInfo.CreateNoWindow = true
p.StartInfo.UseShellExecute = true
p.Start()
'might need to wait a few seconds for the print spooling
System.Threading.Thread.Sleep(5000)
p.Close()
Hope that helps.
Ben
|
|
|
|
|
Hello Ben,
Thanks for the code, it worked great.
Just one thing, about the system.threading. Is this the main UI thread this is sleeping?
What would happen if you don't set the sleep, before the close?
Many thanks,
Steve
|
|
|
|
|
Hey Steve,
It is the main UI thread that is sleeping. If you don't set the sleep and close the process before the print job has spooled then the print job will be canceled.
If you want the app to still be responsive you should do something like thing:
For i As Integer = 1 To 10
System.Threading.Thread.Sleep(500)
Application.DoEvents()
Next i
So you only sleep for 1/2 a second and then process any windows events.
Hope that helps.
Ben
|
|
|
|
|
Hi,
I have a datagridview (.NET 2.0)
In one column I had placed combobox to select values.
I would like to add the images with this values in the combobox
How can I do this
Thanks in advance
Parag
|
|
|
|
|
Is there any way to use DDE in vb.net because I want to communicate with a application called Fiche Finder? Does anyone have any samples using DDE? Any sugestions will help.
jds1207
|
|
|
|
|
Hello !!
I installed Windows 2oo3 SP2 yesterday. Everything works just fine but one thing so far.
I develop asp pages that call COM objects in VB6 but since I installed SP2 I'm unable to launch the COM object from VB and set breakpoints and such... IIS sends the following error '80030019' on the CreateObject line which I don't understand since it's related to seeking records...
(Server.CreateObject gives 'ASP 0177 : 80030019')
Any idea ??!! Am I good to uninstall SP2 ?
Thanks !
|
|
|
|
|
does iuser_/iwam_ have read/execute access to where the dlls are?
|
|
|
|
|
It didn't... I added it but the problem remains the same
I granted iuser_ and iwam_ access from the top of the drive down to the folder where the dlls and sources are.
Any other idea ?
|
|
|
|
|
Still having the problem but
I found out in my Security Log the Machine Debug Manager couldn't be started because the Network Service account didn't have the rights to. I added the proper rights through the dcomcnfg. I don't have the message anymore but my problem remains.
Microsoft Machine Debug Manager configuration
|
|
|
|
|
1) does the system account have access to the dlls
2) the account your logging into when you debug...is that an admin account or...if not, then does it have access to the area of the dlls?
|
|
|
|
|
1) Which account are you referring to ?
2) yes I'm domain and local admin so there should not be a problem there
|
|
|
|
|
Hi All,
Iam writting a console application where user writes in command prompt the following:
ApplicationName.exe "PathOfFile" "PrinterName"
to print a ceratin file.
My issue is that if i chosed a printer that is not set as default on my pc it is not printing.
In other words, i need a command that sets a certain printer on the network to be as my default printer in order to let my application prints the file.
i dont want the user to manully sets the targeted printer as default. I want a script/batch that sets that printer as default and then prints from my application.
Any Ideassss.....
|
|
|
|
|
samerh wrote: dont want the user to manully sets the targeted printer as default. I want a script/batch that sets that printer as default and then prints from my application.
So, you want the user to set the default printer back to what it was after your code runs?
samerh wrote: Iam writting a console application where user writes in command prompt the following:
ApplicationName.exe "PathOfFile" "PrinterName"
Why is the user specifying a printer name if your code doesn't use it? Your code has to be written to use this and not depend on the default printer. There is no single command that's going to fix this problem for you.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Hi,
we have written code to start the 'HH.exe' process with argument passed. And the process is started.
After starting this we are calling MainWindowHandle.ToInt64 of the above process. But am getting 'Process has Exited, so the requested information is not available'. When i check in task manager, the 'HH.exe' is running
Can any one tell me what could be the cause the above issue and solution for it
Thanks
R.Vasanth
|
|
|
|
|
If this "HH.EXE" is a DOS application, there will be no MainWindowHandle.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Hi,
I switched over from VB6 to VB.NET.
In VB6 when we wanted to temprorily disable error handling, we used "Break on all Errors".
How do we disable error handling in VB.NET?
I've Got stuck in a procedure that has a lot of code between the try...catch block and many nested try.. catch blocks too. I want to know which part of the code is generating errors.
Please help.
Thanks,
|
|
|
|
|
Do the errors not throw exceptions? If they do have you tried checking the stack trace for the error? That should at least point you in the right direction.
|
|
|
|
|
There is no equivilent in VB.NET.
Set breakpoints in your catch statements and look at the stack trace,
or set them at the beginning of your Try blocks and step through the code line by line,
or comment out the Try/Catch statements,
or instrument your code and log critical information you need to trace back the errors.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
You said you want to know what part of the code is generating errors. It sounds to me like you actually want the errors to happen as though there is no try...catch block. You can accomplish this by going to Debug > Exceptions and then checking the checkbox for 'common language runtime exceptions' under the 'thrown' column. This should cause the program to break when an error occurs even if it's in the try...catch block.
|
|
|
|
|
Hello,
I am working in Visual Studio.NET 2003. I just want to ask if there is any way I could tell System.Diagnosis.Process to start a new process/window on my desired location. Actually I am working in a Multiple Monitor environment and want System.Diagnosis.Process to open on the second monitor (by setting up location)
<br />
Dim p As System.Diagnostics.Process<br />
Dim pinfo As New System.Diagnostics.ProcessStartInfo<br />
pinfo.Arguments = "C:\WINDOWS\System32\shimgvw.dll,ImageView_Fullscreen c:\Picture 001.jpg"<br />
pinfo.FileName = "C:\windows\system32\rundll32.exe"<br />
Process.Start(pinfo)<br />
Above is a code which i am using to open up Windows Picture and Fax viewer(of which i want to set the location of)
Thanks,
Mubashir
Software Architect
Storan Technologies Inc, USA
Every job is a self portrait of the person who did it.
|
|
|
|
|
You can't tell it which monitor to start on. An application will always show up on the primary monitor, then you move it to the monitor you want. The exception to this is if the application was run before and it saved it's last position, before it closed, so that it can recreate it's window in that same position the next time it runs.
So, you're only choice is to launch the application, get it's window handle, by calling the Win32 API function FindWindow, then sending the appropriate window messages to that handle to move it to the desktop coordinates on the next monitor.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Hi,
i want to copy a line from any text file and paste it to another text file.
let me know how to do that?
regards
pankaj kumar
|
|
|
|
|
Which bit are you stuck on ? You can't insert text into a file, you need to read it, insert it in memory, and overwrite the existing file.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
basically i need to check a checkbox on an access database to therefore block the user from using that account. my code is wrong(below) plus the catch exception is brining up this message "No value given for one or more required parametres"
i think this line of code could be the problem because i keep on getting warningsm on it :- If dr.Read() Then 'if the entry is correct (readable)
can anyone recterfy my code please?
Imports System.Data.OleDb
Public Class Block
Public conn As OleDbConnection
Public comm As OleDbCommand
Public dr As OleDbDataReader
Public da As OleDbDataAdapter
Dim icount As Integer
Private Sub Btnblock_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBlock.Click
'when the logon button is pressed
Dim ManagerLogin As String
'declares the variable
Try
conn = New OleDbConnection 'establishes that conn is a new connection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\PCBank.mdb" 'the name of the connection (name of the database on the end)
conn.Open() 'opens the connection
comm = New OleDbCommand 'establishes that comm is a new command
comm.Connection = conn 'the connection for the command is the connection specified
comm.CommandType = CommandType.Text 'the commands are in text
ManagerLogin = "SELECT DISTINCT Password FROM Accounts WHERE ManagerID='" & Me.tbID.Text & "' "
'the variables value is an SQL command, selects value that is equal to the id AND password.
''MessageBox.Show(ManagerLogin) 'shows the sql command (only needed for testing)
comm.CommandText = ManagerLogin 'the variable is declared as a command
dr = comm.ExecuteReader 'gives the variable a value
conn = New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=PCBank.mdb")
conn.Open()
comm = New OleDbCommand("insert into Accounts(Blocked) values('" & (chBlock.CheckState) & "')", conn)
icount = comm.ExecuteNonQuery()
MsgBox("record inserted")
chBlock.Checked = False
Catch ex As Exception
MsgBox(ex.Message)
If dr.Read() Then 'if the entry is correct (readable)
Me.Close()
Form2.Show() 'show the index varibale (form)
'close the current form
Else 'if the entry is incorrect
MessageBox.Show("Invalid ID, please try again") 'displays error message
tbID.Clear() 'clears the managerid
End If 'end if
End Try
conn.Close()
End Sub
End Class
|
|
|
|
|
I'm not sure, but it looks like you're inserting a new record into a table called Accounts. Shouldn't this be an UPDATE statement that changes as field in the record in question?
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|