I want to have a link through markup in a ReportRecordItem in a ReportControl and to fire an event when I click that link. I have the following code in the Load event of the form. public void Hyperlink_Click(object Sender, object Args)
{
MessageBox.Show("Clicked");
}
private void Form1_Load(object sender, EventArgs e)
{
try
{
axReportControl1.PaintManager.FixedRowHeight = false;
axReportControl1.EnableMarkup = true;
axReportControl1.MarkupContext.SetHandler(this);
axReportControl1.MarkupContext.SetMethod(this, "Hyperlink_Click");
axReportControl1.Columns.Add(0, "ColumnName", 100, true);
var rec = axReportControl1.Records.Add();
var item = rec.AddItem("My link");
item.Caption = "<TextBlock><Hyperlink Click='Hyperlink_Click'>Click this</Hyperlink><LineBreak/> newline link </TextBlock>";
item.CreateEditOptions();
item.EditOptions.EditControlStyle = XTPReportEditStyle.xtpEditStyleMultiline; axReportControl1.Populate();
}
catch (Exception exc)
{
MessageBox.Show(exc.ToString());
}
}
On the line of code "axReportControl1.MarkupContext.SetHandler(this);" the following exception occurs: System.InvalidCastException: Specified cast is not valid. at System.Runtime.InteropServices.Marshal.GetIDispatchForObjectNative(Object o, Boolean onlyInContext) at System.Runtime.InteropServices.Marshal.GetIDispatchForObject(Object o) at System.Runtime.InteropServices.DispatchWrapper..ctor(Object obj) at System.RuntimeType.WrapArgsForInvokeCall(Object[] aArgs, Int32[] aWrapperTypes) at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData) at XtremeReportControl.MarkupContext.SetHandler(Object Handler) at WindowsFormsApplication1.Form1.Form1_Load(Object sender, EventArgs e)
Coding details: C# language, Visual Studio 2010, .net framework 4.0, version of Codejock dll: 15.2.0.0.
Thank for your support.
|