473,418 Members | 2,078 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,418 software developers and data experts.

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 1458
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**@idcodeware.co.uka écrit dans le message de news:
O0*************@TK2MSFTNGP06.phx.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...@idcodeware.co.uka écrit dans le message de news:
O02njKj6HHA....@TK2MSFTNGP06.phx.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 OnMyPropertyChanging(EventArgs.Empty)
_MyProperty = value
If isDifferent Then OnMyPropertyChanged(EventArgs.Empty)
End Set
End Property
Private _MyProperty As String = ""

Public Event MyPropertyChanging As EventHandler
Public Event MyPropertyChanged As EventHandler

Protected Overridable Sub OnMyPropertyChanging(ByVal e As
EventArgs)
RaiseEvent MyPropertyChanging(Me, e)
End Sub

Protected Overridable Sub OnMyPropertyChanged(ByVal e As
EventArgs)
RaiseEvent MyPropertyChanged(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_newsgroups" <ro********@yahoo.comwrote in message
news:11**********************@57g2000hsv.googlegro ups.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...@idcodeware.co.uka écrit dans le message de news:
O02njKj6HHA....@TK2MSFTNGP06.phx.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 OnMyPropertyChanging(EventArgs.Empty)
_MyProperty = value
If isDifferent Then OnMyPropertyChanged(EventArgs.Empty)
End Set
End Property
Private _MyProperty As String = ""

Public Event MyPropertyChanging As EventHandler
Public Event MyPropertyChanged As EventHandler

Protected Overridable Sub OnMyPropertyChanging(ByVal e As
EventArgs)
RaiseEvent MyPropertyChanging(Me, e)
End Sub

Protected Overridable Sub OnMyPropertyChanged(ByVal e As
EventArgs)
RaiseEvent MyPropertyChanged(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
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...
9
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...
4
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...
3
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...
4
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...
3
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...
0
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. ...
2
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...
5
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...
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?
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...
0
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,...
0
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...

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.