Question

I have found aa solution to a problem in one of my reports but its in VB.NET and I am not sure how to convert it to C#, I tried to do it online with one of the tools but it cant determine the events been used or something like that. If there is anyone savy at both languages maybe you can help me figure out its translation? Here is the VB code

Private Sub XrLabel1_BeforePrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs)
Handles XrLabel1.BeforePrint

    CType(sender, XRLabel).Tag = GetCurrentColumnValue("ID")

End Sub



Private Sub XrLabel1_HtmlItemCreated(ByVal sender As Object, ByVal e As
DevExpress.XtraReports.UI.HtmlEventArgs) Handles XrLabel1.HtmlItemCreated

    e.ContentCell.InnerHtml =
String.Format("<a href=http://www.testarea.com/property.aspx?id={1}>{0}</a>", e.ContentCell.InnerText,
e.Data.Tag)

PS: I tried to convert it on this site http://www.developerfusion.com/tools/convert/vb-to-csharp/

THE ORIGINAL CODE IS FOUND HERE http://www.devexpress.com/Support/Center/KB/p/A1107.aspx

Was it helpful?

Solution

private void XrLabel1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
    ((XRLabel)sender).Tag = GetCurrentColumnValue("ID");
}

private void XrLabel1_HtmlItemCreated(object sender, DevExpress.XtraReports.UI.HtmlEventArgs e)
{
    e.ContentCell.InnerHtml = String.Format("<a href=http://www.testarea.com/property.aspx?id={1}>{0}</a>", e.ContentCell.InnerText, e.Data.Tag);
}

But the trick here is that you have to subscribe to the event somewhere, so you'll need this upon initialization:

XrLabel1.BeforePrint += XrLabel1_BeforePrint;
XrLabel1.HtmlItemCreate += XrLabel1_HtmlItemCreated;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top