473,526 Members | 3,222 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# Equivalent to VB's WithEvents?

Hello,

Thanks for reviewing my question. I am following KB article about creating
a custom control and its source code is in VB. I got to a part where I have
the following:

Private WithEvents mBindingList As IbindingList

What would be the C# equivalent? What is the replacement for WithEvents?

private IBindingList mBindingList;

Thanks for the help.
Peter
Nov 16 '05 #1
2 17622
Peter <Pe***@discussions.microsoft.com> wrote:
Thanks for reviewing my question. I am following KB article about creating
a custom control and its source code is in VB. I got to a part where I have
the following:

Private WithEvents mBindingList As IbindingList

What would be the C# equivalent? What is the replacement for WithEvents?


There's no equivalent to WithEvents. You need to add and remove events
manually somewhere in your code. (That's what VB.NET is doing under the
covers, along with changing field declarations into properties with
hidden fields, so that if you change a field value it unhooks the old
event and adds a new one.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
Hi Peter,

There is no WithEvents in C#. Instead, you use the +=, -= operators to add
and remove event handlers.

Try this tutorial from MSDN:
http://msdn.microsoft.com/library/en...tsTutorial.asp

HTH,
Rakesh Rajan

"Peter" wrote:
Hello,

Thanks for reviewing my question. I am following KB article about creating
a custom control and its source code is in VB. I got to a part where I have
the following:

Private WithEvents mBindingList As IbindingList

What would be the C# equivalent? What is the replacement for WithEvents?

private IBindingList mBindingList;

Thanks for the help.
Peter

Nov 16 '05 #3

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

Similar topics

10
6660
by: ST | last post by:
Hi, I'm new to vb.net programming, and I keep getting this error: Name 'GetQuery' is not declared. I can't figure out why?? It seems like I have the right references/namespaces. This is my code below. Also, can someone explain to me what the ContentHandlerImpl.vb file actually does? It's in this project that I'm working with...but I'm...
5
9835
by: Bradley Grant | last post by:
I am trying to write a program to access a device through USB port, there is some Visual Basic program examples that work with the device, but I am trying to write a program using C#, no luck yet, but the problem may lie with the following code that was written in Visual Basic, and I was wondering what the C# equivalent of WithEvents is? ...
2
2865
by: Joe Fetters via .NET 247 | last post by:
Have googled and read the VS.NET documentation can't seem to getthe answer to the following. Environment: Framework 1.1 VB.NET WinForm Access database Using all automagic tools (DataAdapter Wizard with generatedDataset and generated Select, Update, Insert and Deletecommands, controls bound to DataSet using the AdvancedDatabinding...
3
2449
by: Mika M | last post by:
Hi! I try to convert some VB.NET 2003 code into C# 2003 code. Code uses Sax.Communications COM-port control, and VB code is working fine. Here is part of VB Class code I'm trying to convert... Imports Sax.Communications '// Importing component Namespace Private WithEvents _ComPort As SerialConnection '// Declaration Com-port
2
2236
by: Maellic | last post by:
Hi, I'm currently updating a website written with ASP.NET. The original programmer is overseas, there is no documentation, and files are all over the place. Here is a code snippet from one of the .vb file used by the application (the entire code of the file is at the end of the post): If...
20
2843
by: Jason Dravet | last post by:
Some time ago I wrote an application that controls the projectors in our classrooms(turn on, turn off, and volume control). This application is written in VB.net 2003. It was working perfectly until XP SP2 was installed on the PCs. Now when the power on or power off button is pressed the following message is displayed: An unhandled...
2
3724
by: mharness | last post by:
Hello, I've tried a number of examples showing how to read the properties of a user control from an aspx file where the code is on the html view of the form but I can't figure out how to read them from the aspx.vb. Can anyone tell me how to declare the user control in the aspx.vb file so that I can read the properties? I did add...
8
3561
by: Ryan | last post by:
Ok.. I have a form with lots of stuff on it; a tool strip panel, menu strip, data binding elements (dataset, binding source, table adapter), tab control with 7 tab pages, each page contains a picture box, lots of text boxes (for input).. you get the idea. All of a sudden everything on the form has disappeared, it looks like a blank, newly...
47
2173
by: M. Ali Qureshi | last post by:
Hi, I am a beginner in .NET. I have been coding in plain asp before, using VBScript, and now when i'm migrating to .NET, i obviously chosed VB.NET. But.... when i see code samples on net, they are mostly in C#, i also saw a post in this newsgroup where someone mentioned that it was a very "heated topic back in 2002 about VB.NET vs C#". ...
0
7251
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7474
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7231
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7600
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5776
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4812
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3310
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
545
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.