troubleshooting Question code not working after c# conversion (RaisEvent)

Avatar of LIBRALEX
LIBRALEXFlag for South Africa asked on
C#Programming.NET Programming
2 Comments1 Solution562 ViewsLast Modified:
I've converted c# code to but for some reason it doesn't work.Not sure what I missed.
I get an error that says.
'Public Event PositionChanged(sender As Object, e As System.EventArgs)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event."
can someone please help me.

This is in an DevExpress.XtraReport Class
C# Code:
public partial class XtraReportMailingLabels: DevExpress.XtraReports.UI.XtraReport {
        int skipnumber;
        const int skip = 11;
        public XtraReportMailingLabels() {
            skipnumber = skip;
        private void xrPanel1_BeforePrint (object sender, System.Drawing.Printing.PrintEventArgs e) {
            if(skipnumber >= 0 ) {
                e.Cancel = true;
        private void Detail_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {
            if(skipnumber > 0) {
                DevExpress.Data.Browsing.DataBrowser browser = this.fDataContext[this.DataSource, this.DataMember];
                browser.PositionChanged += new EventHandler(browser_PositionChanged);
        bool stop = false;
        void browser_PositionChanged(object sender, EventArgs e) {
            ((DevExpress.Data.Browsing.ListBrowser)(sender)).PositionChanged -= browser_PositionChanged;
            ((DevExpress.Data.Browsing.ListBrowser)(sender)).Position =0;
        if(skipnumber <= 0) {
            stop = true;
Public Class XtraReportMailingLabels
    Inherits DevExpress.XtraReports.UI.XtraReport
    Private skipnumber As Integer
    Const skip As Integer = 11
    Public Sub New()
        skipnumber = skip
    End Sub
    Private Sub xrPanel1_BeforePrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles XrPanel1.BeforePrint
        If skipnumber >= 0 Then
            e.Cancel = True
        End If
    End Sub
    Private Sub Detail_BeforePrint(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles Detail.BeforePrint
        If skipnumber > 0 Then
            Dim browser As DevExpress.Data.Browsing.DataBrowser = Me.fDataContext(Me.DataSource, Me.DataMember)
            AddHandler browser.PositionChanged, AddressOf browser_PositionChanged
        End If
        skipnumber -= 1
    End Sub
    Private [stop] As Boolean = False
    Private Sub browser_PositionChanged(ByVal sender As Object, ByVal e As EventArgs)
        DirectCast((sender), DevExpress.Data.Browsing.ListBrowser).PositionChanged -= browser_PositionChanged()
        If Not [stop] Then
            DirectCast((sender), DevExpress.Data.Browsing.ListBrowser).Position = 0
        End If
        If skipnumber <= 0 Then
            [stop] = True
        End If
    End Sub
End Class

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros