in

C1 Community

ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

Capture toolbar button click

Last post 03-26-2008 4:15 PM by lsteury. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 01-25-2008 5:09 PM

    Capture toolbar button click

    I need help converting the following to v2, I am not having much luck:

     Private Sub PrintPreviewButtonPressed(ByVal Sender As Object, ByVal e As
    C1.Win.C1PrintPreview.PreviewToolBarButtonClickEventArgs) Handles
    C1PrintPreview1.PreviewButtonClick
    If Not e Is Nothing Then
    Select Case e.Action
    Case C1.Win.C1PrintPreview.ToolBarButtonActionEnum.FilePrint
    Debug.WriteLine("Document should be printed")
    Case C1.Win.C1PrintPreview.ToolBarButtonActionEnum.FileSave
    Debug.WriteLine("Document should be saved")
    End Select
    End If
    End Sub


     

  • 01-28-2008 5:09 PM In reply to

    • C1_GregL
    • Top 10 Contributor
    • Joined on 06-11-2007
    • Pittsburgh PA
    • Posts 516

    Re: Capture toolbar button click

    To capture the user clicking on a toolbar button (example: Print):

    AddHandler C1PrintPreviewControl1.ToolBars.File.ToolStrip.Items(3).Click, AddressOf onPrintClick

    Private Sub onPrintClick(ByVal sender As System.Object, ByVal e As System.EventArgs)
    'Captured
    End Sub

    Use this technique for each button as needed.  I haven't seen a better way yet.

    Hope that helps,
    Greg L

  • 03-20-2008 5:13 PM In reply to

    Re: Capture toolbar button click

    I was able to capture the print button click, but I need to know if the user selected print or cancel from the print dialog box.  I used to use the following code:

    If e.action = C1.Win.C1PrintPreview.ToolBarButtonActionEnum.FilePrint then

        If Me.C1PrintPreview1.Print() then

              SaveUpdate()

         End if

    End if

    Thanks, Laura

  • 03-24-2008 2:13 PM In reply to

    Re: Capture toolbar button click

    If you use the C1PrintPreviewControl.PreviewPane.Print() to print, you can check its return value, i.e.:

    If Me.C1PrintPreviewControl1.PreviewPane.Print() Then
      SaveUpdate()
    End If

    Hope this helps.
     

    Cheers,
    Dima.
  • 03-24-2008 2:41 PM In reply to

    Re: Capture toolbar button click

    Thanks, that was exactly what I was looking for. 

    In the previous version I was capturing the PreviewButtonClick to decide if they and printed or saved.  Do I have to AddHandler as stated previously or what is the code to capture without having to know the button's item number?

     Here is my OLD (2003) example.

    Private Sub C1PrintPreview1_PreviewButtonClick(ByVal sender As Object, ByVal e As C1.Win.C1PrintPreview.PreviewToolBarButtonClickEventArgs) Handles C1PrintPreview1.PreviewButtonClick

    If e.Action = C1.Win.C1PrintPreview.ToolBarButtonActionEnum.FilePrint Then

    If Me.C1PrintPreview1.Print() Then

    'user pressed OK

    SaveUpdate()

    End If

    e.Handled = True

    ElseIf e.Action = C1.Win.C1PrintPreview.ToolBarButtonActionEnum.FileSave Then

    If Me.C1PrintPreview1.FileSave Then

    'user saved file

    SaveUpdate()

    End If

    e.Handled = True

    End If

    End Sub

  • 03-24-2008 5:15 PM In reply to

    Re: Capture toolbar button click

    First please note that all buttons are accessible via properties without using indices, e.g. the print button can be accessed as:

    c1PrintPreviewControl1.ToolBars.File.Print

    directly.

    For default handling, the toolbar buttons are identified by their tags. Accordingly, you can turn the default action on or off by setting the tag property on the corresponding button. For instance, the following code turns default handling off and provides custom handling for the print button:

    c1PrintPreviewControl1.ToolBars.File.Print.Tag = Nothing
    ...
    Private Sub PrintButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles c1PrintPreviewControl1.ToolBars.File.Print.Click
      If c1PrintPreviewControl1.PreviewPane.Print() Then
        ' document was printed
      Else
        ' user canceled printing
      End If
    End Sub

    For a complete sample showing this technique please see ToolbarButtonsOverride.zip. Hope this helps.


    Cheers,
    Dima.
  • 03-26-2008 4:15 PM In reply to

    Re: Capture toolbar button click

    Thanks, problem solved!  Laura

Page 1 of 1 (7 items)
Contact ComponentOne: 1.800.858.2739 ©1987-2008 ComponentOne LLC All Rights Reserved.