Avatar of Marianne VAN WYK
Marianne VAN WYK
Flag for South Africa

asked on 

vb.net code not working after c# conversion (RaisEvent)

I've converted c# code to vb.net 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

Open in new window

C#Programming.NET Programming

Avatar of undefined
Last Comment

8/22/2022 - Mon