Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

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

Avatar of LIBRALEX
LIBRALEXFlag for South Africa asked on
Programming.NET ProgrammingC#
2 Comments1 Solution562 ViewsLast Modified:
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
Avatar of pivar
pivarFlag of Sweden image

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

This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answers