Codejock Forums Homepage
Forum Home Forum Home > General > XAML Snippets
  New Posts New Posts RSS Feed - XAML button in ReportControl
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

XAML button in ReportControl

 Post Reply Post Reply
Author
Message
Pidi View Drop Down
Newbie
Newbie


Joined: 04 March 2009
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote Pidi Quote  Post ReplyReply Direct Link To This Post Topic: XAML button in ReportControl
    Posted: 06 February 2013 at 3:46pm
I'd like to use XAML to add a button to my ReportControl.

I tried something like this:


'<StackPanel>' + ;
'<Button Margin="2" Cursor="Hand">' + ;
'<TextBlock HorizontalAlignment="Center">' + sString + '</TextBlock>' + ;
'</Button>' + ;
'</StackPanel>'


This works fine, however, it doesn't "function" as a button. When clicked upon, it doesn't press down.

Is it possible what I want?
Back to Top
jpbro View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 January 2007
Status: Offline
Points: 1355
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpbro Quote  Post ReplyReply Direct Link To This Post Posted: 22 February 2013 at 9:17am
Yes, this is possible. First make sure that you are using the latest version of the ReportControl (15.3.1), as I believe there were bugs in earlier implementations that prevented this from working (although you are free to try with an older version, I may be mistaken).

Next you need to make call the ReportControl.MarkupContext.SetHandler method. The value you pass depends on your language. In VB6, you would call ReportControl1.MarkupContext.SetHandler Me, but other languages will be different (I can't help you if you aren't using VB6).

Next, you need to include the Click event in your button XAML (something like "<Button Click='ClickButton'>ButtonTest</Button>")

Next, you need to create a Public method in your handler object that will accept the button click event from the reportcontrol. In VB6 the declaration would be Public Sub ClickButton(po_Sender As Object, po_Args As Object). Other languages will be different of course.

Then everything should work.  Here's a VB6 sample that you can examine and possibly translate to the language of your choice:


Option Explicit

Private Sub Form_Load()
   With Me.ReportControl1
      With .Columns.Add(0, "Test", 100, True)
      End With
  
      .EnableMarkup = True
      .MarkupContext.SetHandler Me
     
      With .Records.Add
         With .AddItem("")
            .Caption = "<StackPanel><Button Click='ClickButton' Margin='2' Cursor='Hand'><TextBlock HorizontalAlignment='Center'>Test</TextBlock></Button></StackPanel>"
         End With
      End With
  
      .Populate
   End With
End Sub

Public Sub ClickButton(po_Sender As Object, po_Args As Object)
   MsgBox "Button Clicked!"
End Sub


NOTE: This sub-forum is typically used for XAML snippets - e.g. samples, ideas, experiments, etc... If you post to the ReportControl forum (ActiveX or MFC depending on your library type), you will likely see a quicker response to your questions.
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.219 seconds.