473,785 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tracking change of control variable.

tc
I'm trying to put together a small control. It's not, but for arguments
sake, let's say it's a progress bar.

The user will make a change to a setting, lets call it 'value'.

I want to trap the change of the public variable in the controls code so I
can act on that change.

How would I do that?
Aug 29 '07 #1
3 1472
Use a property instead of a public variable :
http://msdn2.microsoft.com/en-us/lib...57(VS.80).aspx

You may want to read the whole spec at least once so that you know what is
available :
http://msdn2.microsoft.com/en-us/lib...37(vs.80).aspx

---
Patrice

"tc" <tu**@idcodewar e.co.uka écrit dans le message de news:
O0************* @TK2MSFTNGP06.p hx.gbl...
I'm trying to put together a small control. It's not, but for arguments
sake, let's say it's a progress bar.

The user will make a change to a setting, lets call it 'value'.

I want to trap the change of the public variable in the controls code so I
can act on that change.

How would I do that?

Aug 29 '07 #2
On Aug 29, 8:06 am, "Patrice" <http://www.chez.com/scribe/wrote:
Use a property instead of a public variable :http://msdn2.microsoft.com/en-us/lib...57(VS.80).aspx

You may want to read the whole spec at least once so that you know what is
available :http://msdn2.microsoft.com/en-us/lib...37(vs.80).aspx

---
Patrice

"tc" <t...@idcodewar e.co.uka écrit dans le message de news:
O02njKj6HHA.... @TK2MSFTNGP06.p hx.gbl...
I'm trying to put together a small control. It's not, but for arguments
sake, let's say it's a progress bar.
The user will make a change to a setting, lets call it 'value'.
I want to trap the change of the public variable in the controls code so I
can act on that change.
How would I do that?
To build on Patrice's statements:

I would change the public variable (which should almost always be
avoided imo) into a public property. In the Set accessor I would
inspect the value to see if it is different than the current value and
if so I would fire off the necessary events.

Something like (untested):

//////////////////////
Public Class TheClass

Public Property MyProperty() As String
Get
Return _MyProperty
End Get
Set(ByVal value As String)
Dim isDifferent As Boolean = (value <_MyProperty)
If isDifferent Then OnMyPropertyCha nging(EventArgs .Empty)
_MyProperty = value
If isDifferent Then OnMyPropertyCha nged(EventArgs. Empty)
End Set
End Property
Private _MyProperty As String = ""

Public Event MyPropertyChang ing As EventHandler
Public Event MyPropertyChang ed As EventHandler

Protected Overridable Sub OnMyPropertyCha nging(ByVal e As
EventArgs)
RaiseEvent MyPropertyChang ing(Me, e)
End Sub

Protected Overridable Sub OnMyPropertyCha nged(ByVal e As
EventArgs)
RaiseEvent MyPropertyChang ed(Me, e)
End Sub

End Class
////////////////////

That way you have events that can notify any listeners both before and
after the change to the property occurs.

Thanks,

Seth Rowe

Aug 29 '07 #3
tc
Thanks for your input peeps.

"rowe_newsgroup s" <ro********@yah oo.comwrote in message
news:11******** **************@ 57g2000hsv.goog legroups.com...
On Aug 29, 8:06 am, "Patrice" <http://www.chez.com/scribe/wrote:
Use a property instead of a public variable
:http://msdn2.microsoft.com/en-us/lib...57(VS.80).aspx

You may want to read the whole spec at least once so that you know what is
available :http://msdn2.microsoft.com/en-us/lib...37(vs.80).aspx

---
Patrice

"tc" <t...@idcodewar e.co.uka écrit dans le message de news:
O02njKj6HHA.... @TK2MSFTNGP06.p hx.gbl...
I'm trying to put together a small control. It's not, but for arguments
sake, let's say it's a progress bar.
The user will make a change to a setting, lets call it 'value'.
I want to trap the change of the public variable in the controls code so
I
can act on that change.
How would I do that?
To build on Patrice's statements:

I would change the public variable (which should almost always be
avoided imo) into a public property. In the Set accessor I would
inspect the value to see if it is different than the current value and
if so I would fire off the necessary events.

Something like (untested):

//////////////////////
Public Class TheClass

Public Property MyProperty() As String
Get
Return _MyProperty
End Get
Set(ByVal value As String)
Dim isDifferent As Boolean = (value <_MyProperty)
If isDifferent Then OnMyPropertyCha nging(EventArgs .Empty)
_MyProperty = value
If isDifferent Then OnMyPropertyCha nged(EventArgs. Empty)
End Set
End Property
Private _MyProperty As String = ""

Public Event MyPropertyChang ing As EventHandler
Public Event MyPropertyChang ed As EventHandler

Protected Overridable Sub OnMyPropertyCha nging(ByVal e As
EventArgs)
RaiseEvent MyPropertyChang ing(Me, e)
End Sub

Protected Overridable Sub OnMyPropertyCha nged(ByVal e As
EventArgs)
RaiseEvent MyPropertyChang ed(Me, e)
End Sub

End Class
////////////////////

That way you have events that can notify any listeners both before and
after the change to the property occurs.

Thanks,

Seth Rowe
Sep 19 '07 #4

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

Similar topics

2
4401
by: Steve Mew | last post by:
Has anyone come across a change tracking tool for SQL Server. Specifically the scenario I want is the following : A Production DB needs some modifications to its content. This tool will copy the DB to a dev environment. The Dev environment will be 2 copies of the DB, 1 as a control set and the other the change DB. The developer makes their changes in the Change DB. They test them out and then when they decide the changes are ready to...
9
3094
by: goks | last post by:
I'm using document.referrer method for tracking visits on my site. But it seems that, when someone finds my site with google, this method returns only: "google.com/search?q=xxxxx" (good) or "google.com/search?hl=en" (bad) or "google.com/search?sourceid=navclient" (bad) That meens, it returns only first parameter sent to google. "hl" defines
4
2366
by: pjac | last post by:
I need assistance in creating an Automatic tracking number that appears in a textbox that looks like: 2004-001. The first part of the number is based on the year, the second part is generated from the last available number used. Also, the second part of the number needs to start over whenever a new year is started. for example: 2005-001. Any help would be greatly appreciated. Thanks, pjac
3
2818
by: Kyle Friesen via AccessMonster.com | last post by:
Mike, I have databse that creates a "tracking number" based on the selections made on the form via concatenating. At the end of the tracking number, I need a two digit (01-99) sequence number by product group for each customer. Hpw do I do this without creating a table for each customer and each product group with autonumbers. For example based on the entries in this sample, the desired result would be: Customer Business Unit Tracking...
4
1640
by: moogyd | last post by:
Hi, (Off-topic) I am looking to put an open-source bug/issue tracking system in place for our current project (eventually expanded for all projects), and would appreciate any experiences/comments/suggestions. Note the project is encompasses embedded hardware (ASIC plus firmware) plus application software.
3
2518
by: =?Utf-8?B?R3JhaGFt?= | last post by:
I've added 2 tracking services to the wf runtime; one is the standard SqlTrackingService: trackingService = new SqlTrackingService(<trackingConnectionString>); <workflow Runtime>.AddService(trackingService); trackingService.IsTransactional = false; trackingService.UseDefaultProfile = true; This works just fine.
0
1799
by: LiveTecs | last post by:
http://www.livetecs.com TimeLive Web Collaboration Suite is an integrated suite that allows you to manage project life cycle including tasks, issues, bugs, timesheet, expense, attendance. TimeLive is available in two different flavors. Hosted version and downloadable version. Downloadable version required certain system requirement to install on local server. Whereas hosted version is already installed on our fully managed server on...
2
1326
by: sparks | last post by:
At first they just wanted to keep a record of who logged in and when. Then it was if they made changes. Now its who changed what. BUT since this made no since to them. WHO put it in and who changed it. WTF are they talking about. So every variable will have to be logged at entry and later IF someone changes it it will have to be logged like from and to ...then by who and when ???
5
2347
by: jennic | last post by:
Hi, I have an online shop that uses Sunshop php shopping cart and I have attempted to get help through their forum but no-one responds with assistance. I need to install a tracking code on my site and I was given the tracking code and told I need to insert the variable names for the order total and sales id. But I have no idea what these are where to find them. The tracking code looks like this <img height="1" width="1"...
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10329
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10152
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10092
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8974
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5381
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.