Marianne VAN WYK
asked on
vb.net code not working after c# conversion (RaisEvent)
Hi,
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
Regards
Will
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
Regards
Will
C# Code:
public partial class XtraReportMailingLabels: DevExpress.XtraReports.UI.XtraReport {
int skipnumber;
const int skip = 11;
public XtraReportMailingLabels() {
InitializeComponent();
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);
}
skipnumber--;
}
bool stop = false;
void browser_PositionChanged(object sender, EventArgs e) {
((DevExpress.Data.Browsing.ListBrowser)(sender)).PositionChanged -= browser_PositionChanged;
if(!stop)
((DevExpress.Data.Browsing.ListBrowser)(sender)).Position =0;
if(skipnumber <= 0) {
stop = true;
}
}
}
VB CODE:
Public Class XtraReportMailingLabels
Inherits DevExpress.XtraReports.UI.XtraReport
Private skipnumber As Integer
Const skip As Integer = 11
Public Sub New()
InitializeComponent()
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
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Open in new window