Cancel print

This just cancels...I need to show the dialog and allow the user to either cancel or print...I am not getting anywhere with this code. Even though this is vb net, the code should be the same or similar in C#

-------------------------------------------------
        PrintFormulas.ShowDialog()

        If CBool(Windows.Forms.DialogResult.Cancel) = True Then

            MsgBox("Printing Canceled")

        Else
            If CBool(Windows.Forms.DialogResult.OK) Then


                PD.Print()
            End If
        End If
LVL 1
mindserveAsked:
Who is Participating?
 
SriVaddadiCommented:
Dim result as DialogResult
result =  PrintFormulas.ShowDialog()

        If result == DialogResult.Cancelled Then

            MsgBox("Printing Canceled")

        Else
            If result == Windows.Forms.DialogResult.OK) Then


                PD.Print()
            End If
        End If
0
 
vikas413Commented:
If Windows.Forms.DialogResult =  DialogResult.Cancelled Then

            MsgBox("Printing Canceled")

        Else
            If CBool(Windows.Forms.DialogResult.OK) Then


                PD.Print()
            End If
        End If
0
 
mindserveAuthor Commented:
Made some slight changes to your code but it works! ThX

 Dim result As DialogResult
        result = PrintFormulas.ShowDialog()

        If result = Windows.Forms.DialogResult.Cancel Then

            MsgBox("Printing Canceled")

        Else
            If result = Windows.Forms.DialogResult.OK Then


                PD.Print()
            End If
        End If
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
mindserveAuthor Commented:
OOps...accepted the wrong person. Both code works though..should I split the points ..too late now?
0
 
SriVaddadiCommented:
You could request attention to the adminstrator and split the points
0
 
mindserveAuthor Commented:
Ok, will do that
0
 
SriVaddadiCommented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.