473,387 Members | 1,420 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,387 software developers and data experts.

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 17612
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
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...
5
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,...
2
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...
3
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......
2
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...
20
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...
2
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...
8
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...
47
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
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...

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.