473,396 Members | 1,826 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

vb.net to c# eventhandler conversion help Please

Hi everyone, i have a vb.net program ive converted most of the code but

i 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(ma inList_LeaveControl);

this.mainList.Selected += new
dmControls.ListControl.SelectedEventHandler(mainLi st_Selected);
this.mainList.SelectionChanged += new
dmControls.ListControl.SelectionChangedEventHandle r(mainList_SelectionChang**ed);


}
protected delegate void
MainListLeaveControlEventHandler(dmControls.Direct ion direction);
private MainListLeaveControlEventHandler MainListLeaveControlEvent;
protected event MainListLeaveControlEventHandler MainListLeaveControl
{
add { MainListLeaveControlEvent =
(MainListLeaveControlEventHandler)System.Delegate. Combine(MainListLeaveCont**rolEvent,
value); }
remove { MainListLeaveControlEvent =
(MainListLeaveControlEventHandler)System.Delegate. Remove(MainListLeaveContr**olEvent,

value); }

}
protected delegate void MainListSelectedEventHandler(string sSelected,
object Data);
protected MainListSelectedEventHandler MainListSelectedEvent;
protected event MainListSelectedEventHandler MainListSelected
{
add { MainListSelectedEvent =
(MainListSelectedEventHandler)System.Delegate.Comb ine(MainListSelectedEvent**,
value); }
remove { MainListSelectedEvent =
(MainListSelectedEventHandler)System.Delegate.Remo ve(MainListSelectedEvent,

value); }

}
protected delegate void MainListSelectionChangedEventHandler(string
sSelected, object Item);
private MainListSelectionChangedEventHandler
MainListSelectionChangedEvent;
protected event MainListSelectionChangedEventHandler
MainListSelectionChanged
{
add { MainListSelectionChangedEvent =
(MainListSelectionChangedEventHandler)System.Deleg ate.Combine(MainListSelec**tionChangedEvent,
value); }
remove { MainListSelectionChangedEvent =
(MainListSelectionChangedEventHandler)System.Deleg ate.Remove(MainListSelect**ionChangedEvent,

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

Mar 15 '06 #1
0 1371

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sandor Heese | last post by:
Question, When using BeginInvoke (on a From to marshal to the UI thread) with the EventHandler delegate I see some strange behaviour. The problem is that I call the UpdateTextBox method with a...
0
by: dominosly | last post by:
Okay, this is a rather complicated problem, so here is the short of it: I am using a custom designed user control that simply writes out a plain old html submit button to the page. When the...
5
by: JMWilton | last post by:
Is there a way to determine what has been added to the eventhandler list? I have code that uses += and -= to turn event handling code on and off. Apparently, it is possible to add the same event...
4
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new...
9
by: Christopher Weaver | last post by:
Can anyone tell me how I could iterate through a collection of controls on a form while assigning their event handlers to another identical collection of controls on the same form. So far,...
13
by: jac | last post by:
Hae, I have a windows form with a ComboBox an other things. On that combobox I have an eventhandler on de selectedindexchanged. But somewhere in my code want to do excecute the same code that...
2
by: mawi | last post by:
Hi there, When removing page children controls created dynamically not in last-to-first order, the close button of the last control looses its event wiring, even though the handler is rewired...
2
by: i676373 | last post by:
Hi, I have a instance of Button, button1. button1.Click event is already associated with some unknown event handler, e.g. ======= button1.Click += new EventHandler(btn_click1); button1.Click...
5
by: c#2006user | last post by:
Hi everyone, i have a vb.net program ive converted most of the code but i know events dont translate well, the original vb.net code uses withevents and .handles and i can't get the events in c# to...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.