|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
vb.net to c# conversion help pleasei know events dont translate well, the original vb.net code uses withevents and .handles and i can't get the events in c# to work 100% they seem to hook up ok but when the eventhandler is called from the method its null and fails. or maybe im reading it wrong? public abstract class Page : IDisposable { protected ListControl mainList; public virtual void DisplayPage(ref frmMain myForm) { this.mainList.LeaveControl += new dmControls.ListControl.LeaveControlEventHandler(mainList_LeaveControl); this.mainList.Selected += new dmControls.ListControl.SelectedEventHandler(mainList_Selected); this.mainList.SelectionChanged += new dmControls.ListControl.SelectionChangedEventHandler(mainList_SelectionChanged); } protected delegate void MainListLeaveControlEventHandler(dmControls.Direction direction); private MainListLeaveControlEventHandler MainListLeaveControlEvent; protected event MainListLeaveControlEventHandler MainListLeaveControl { add { MainListLeaveControlEvent = (MainListLeaveControlEventHandler)System.Delegate.Combine(MainListLeaveControlEvent, value); } remove { MainListLeaveControlEvent = (MainListLeaveControlEventHandler)System.Delegate.Remove(MainListLeaveControlEvent, value); } } protected delegate void MainListSelectedEventHandler(string sSelected, object Data); protected MainListSelectedEventHandler MainListSelectedEvent; protected event MainListSelectedEventHandler MainListSelected { add { MainListSelectedEvent = (MainListSelectedEventHandler)System.Delegate.Combine(MainListSelectedEvent, value); } remove { MainListSelectedEvent = (MainListSelectedEventHandler)System.Delegate.Remove(MainListSelectedEvent, value); } } protected delegate void MainListSelectionChangedEventHandler(string sSelected, object Item); private MainListSelectionChangedEventHandler MainListSelectionChangedEvent; protected event MainListSelectionChangedEventHandler MainListSelectionChanged { add { MainListSelectionChangedEvent = (MainListSelectionChangedEventHandler)System.Delegate.Combine(MainListSelectionChangedEvent, value); } remove { MainListSelectionChangedEvent = (MainListSelectionChangedEventHandler)System.Delegate.Remove(MainListSelectionChangedEvent, value); } } private void mainList_LeaveControl(Direction direction) { .......................... } private void mainList_Selected(string sSelected, object Data) { if (MainListSelectedEvent != null) MainListSelectedEvent(sSelected, Data); } } DisplayPage is then overridden and called from different type of pages that inherit from page. its the MainListSelectedEvent thats null when i try and call it. any help really appreciated! thanks. bryan Htpc,
Are you sure that you ask this in the right newsgroup. You are asking something about C# code. That has its own newsgroup. Cor <htpc_2***@hotmail.com> schreef in bericht news:1142470413.691475.231440@j33g2000cwa.googlegroups.com... Hi everyone, i have a vb.net program ive converted most of the code buti know events dont translate well, the original vb.net code uses withevents and .handles and i can't get the events in c# to work 100% they seem to hook up ok but when the eventhandler is called from the method its null and fails. or maybe im reading it wrong? public abstract class Page : IDisposable { protected ListControl mainList; public virtual void DisplayPage(ref frmMain myForm) { this.mainList.LeaveControl += new dmControls.ListControl.LeaveControlEventHandler(mainList_LeaveControl); this.mainList.Selected += new dmControls.ListControl.SelectedEventHandler(mainList_Selected); this.mainList.SelectionChanged += new dmControls.ListControl.SelectionChangedEventHandler(mainList_SelectionChanged); } protected delegate void MainListLeaveControlEventHandler(dmControls.Direction direction); private MainListLeaveControlEventHandler MainListLeaveControlEvent; protected event MainListLeaveControlEventHandler MainListLeaveControl { add { MainListLeaveControlEvent = (MainListLeaveControlEventHandler)System.Delegate.Combine(MainListLeaveControlEvent, value); } remove { MainListLeaveControlEvent = (MainListLeaveControlEventHandler)System.Delegate.Remove(MainListLeaveControlEvent, value); } } protected delegate void MainListSelectedEventHandler(string sSelected, object Data); protected MainListSelectedEventHandler MainListSelectedEvent; protected event MainListSelectedEventHandler MainListSelected { add { MainListSelectedEvent = (MainListSelectedEventHandler)System.Delegate.Combine(MainListSelectedEvent, value); } remove { MainListSelectedEvent = (MainListSelectedEventHandler)System.Delegate.Remove(MainListSelectedEvent, value); } } protected delegate void MainListSelectionChangedEventHandler(string sSelected, object Item); private MainListSelectionChangedEventHandler MainListSelectionChangedEvent; protected event MainListSelectionChangedEventHandler MainListSelectionChanged { add { MainListSelectionChangedEvent = (MainListSelectionChangedEventHandler)System.Delegate.Combine(MainListSelectionChangedEvent, value); } remove { MainListSelectionChangedEvent = (MainListSelectionChangedEventHandler)System.Delegate.Remove(MainListSelectionChangedEvent, value); } } private void mainList_LeaveControl(Direction direction) { .......................... } private void mainList_Selected(string sSelected, object Data) { if (MainListSelectedEvent != null) MainListSelectedEvent(sSelected, Data); } } DisplayPage is then overridden and called from different type of pages that inherit from page. its the MainListSelectedEvent thats null when i try and call it. any help really appreciated! thanks. bryan
exe/dll as scheduled task
Icons in Application Menus VB.Net File.Copy Conundrum Access, OLE & VB.NET How To Cancel Edits on a control? Setting Foreground Color Property at Row Level in Datagrid How Many SQL Connections Should I Use? Tracking changes made to form... Name 'ADODB' is not declared Error Printing Question |
|||||||||||||||||||||||