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

need advice on how to best do this



Hi

Looking for advice on best way to implement this idea

I have a form with 10 text boxes, and one button. when user clicks
button i want to transmit info in text boxes to a device, but i only
want to transmit data from textboxes that user has changed data in
since last button click

How can i check if the text box contents have been changed by user, so
i only transmit those ones and dont have to transmit data from all of
them.
May 9 '07 #1
9 1349
This would be a two-step process. First you need to have a Dictionary
that is keyed on the textbox references.

You should have a routine which will cycle through the textbox, and set
the values in the dictionary to false based on the references as keys.

Then, have a TextChanged event handler set up for all of the textboxes
so they all point to the same textbox.

In the event handler, use the sender parameter to find the key in the
dictionary, and then set the value to true.

When you click the button, cycle through the keys (which are the
references to the textboxes) and for the keys that have values of true, send
your values. As you cycle through the keys and process the text, set the
value in the dictionary back to false.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<Petedwrote in message news:lp********************************@4ax.com...
>

Hi

Looking for advice on best way to implement this idea

I have a form with 10 text boxes, and one button. when user clicks
button i want to transmit info in text boxes to a device, but i only
want to transmit data from textboxes that user has changed data in
since last button click

How can i check if the text box contents have been changed by user, so
i only transmit those ones and dont have to transmit data from all of
them.


May 9 '07 #2
On Tue, 08 May 2007 19:39:48 -0700, <Petedwrote:
I have a form with 10 text boxes, and one button. when user clicks
button i want to transmit info in text boxes to a device, but i only
want to transmit data from textboxes that user has changed data in
since last button click

How can i check if the text box contents have been changed by user, so
i only transmit those ones and dont have to transmit data from all of
them.
In addition to what Nicholas wrote, keep in mind that the exact
implementation depends on your definition of "changed by the user". His
suggestion handles the definition of the user actually editing the text
box, whether the net results of the edit result in the same value as the
previous one or not. You could alternatively save all the original values
and compare them after the button is pushed. Or if you go to the other
extreme in defining "changed by the user", you could instead handle
KeyPress or KeyDown events in the textbox, considering a textbox as
"changed" any time the user does any input to the textbox, even if that
input doesn't result in the text changing.

Pete
May 9 '07 #3
On Tue, 08 May 2007 20:05:36 -0700, Nicholas Paldino [.NET/C# MVP]
<mv*@spam.guard.caspershouse.comwrote:
[...]
Then, have a TextChanged event handler set up for all of the
textboxes so they all point to the same textbox.
I presume you meant to write "all point to the same method". :)

Also, assuming the Tag property of each textbox isn't already in use for
some other purpose, an alternative to using the Dictionary might be to
just keep an array of Booleans, with an index into the array stored in the
Tag property. Not that performance would be a concern here (though doing
it this way does optimize the speed of the tracking when things change),
but one might consider it a simpler implementation to do it that way.
When the button is pushed, then one just enumerates all of the textboxes,
handling just those that have the flag set in the array.

Pete
May 9 '07 #4
How about you use DataBindings to bind the Text of the TextBox to an
object that tracks state? i.e.

public sealed class DeviceOption { // ? name
public string Text {...} // optionally with change notification
public string OldText {...}
public DeviceOption(string text) {Text=OldText=text;}
public bool IsDirty {get{return Text!=OldText;}}
}
....
DeviceOption opt = new DeviceOption("abc");
textbox1.DataBindings.Add("Text",opt,"Text");
.....
foreach(DeviceOption opt in options) {
if(opt.IsDirty) {...}
}

You can do similar just toggling a flag on change, but personally I
like it when I change a value from A to B and back to A, then it
treats it as "clean".

Marc

May 9 '07 #5
<Petedwrote in message news:lp********************************@4ax.com...
Looking for advice on best way to implement this idea

I have a form with 10 text boxes, and one button. when user clicks
button i want to transmit info in text boxes to a device, but i only
want to transmit data from textboxes that user has changed data in
since last button click

How can i check if the text box contents have been changed by user, so
i only transmit those ones and dont have to transmit data from all of
them.
Hi Peted, everyone's given you some various ideas on the implementation of
this. First I would look at how you want to solve the problem. Basically you
need to store what *you* consider to be the previous value *somewhere*. It
doesn't matter if that's in a dictionary, array, tag property or whatever.
Somewhere that previous value has to be stored. You have to decide what to
set it to initially (do you read from the device), when to update it etc.
Once you've worked that out then decide how you'll store it.

A couple of solutions not already presented is to just store it in an array
and the other option is to inherit the textbox and make it a property of the
textbox.

Michael
May 9 '07 #6
On Tue, 08 May 2007 21:36:55 -0700, Michael C <no****@nospam.comwrote:
[...]
Basically you
need to store what *you* consider to be the previous value *somewhere*.
Well, no. That was the point of the response from Nicholas. His
suggestion doesn't rely on tracking the previous value; it just keys off
of whether the user does something to cause the TextChanged event to occur.

The difference between that and what you suggest was the point of my post.
A couple of solutions not already presented is to just store it in an
array
I offered this option.
and the other option is to inherit the textbox and make it a property of
the textbox.
Yes, that's yet another way to track the changes. :)

Pete
May 9 '07 #7
"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
>Basically you
need to store what *you* consider to be the previous value *somewhere*.

Well, no. That was the point of the response from Nicholas. His
suggestion doesn't rely on tracking the previous value; it just keys off
of whether the user does something to cause the TextChanged event to
occur.
That is possible although a poorer solution in most cases. Either way he
still needs to decide what he actually wants to do and then decide how to
store the data as *seperate* issues.
The difference between that and what you suggest was the point of my post.
I didn't read everything too thoroughly.
>A couple of solutions not already presented is to just store it in an
array

I offered this option.
I missed that.
>and the other option is to inherit the textbox and make it a property of
the textbox.

Yes, that's yet another way to track the changes. :)

Pete

May 9 '07 #8
thanks to everyone for all the good advice, i will have a look and see
what works best

cheers
On Wed, 9 May 2007 16:27:39 +1000, "Michael C" <no****@nospam.com>
wrote:
>"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
>>Basically you
need to store what *you* consider to be the previous value *somewhere*.

Well, no. That was the point of the response from Nicholas. His
suggestion doesn't rely on tracking the previous value; it just keys off
of whether the user does something to cause the TextChanged event to
occur.

That is possible although a poorer solution in most cases. Either way he
still needs to decide what he actually wants to do and then decide how to
store the data as *seperate* issues.
>The difference between that and what you suggest was the point of my post.

I didn't read everything too thoroughly.
>>A couple of solutions not already presented is to just store it in an
array

I offered this option.

I missed that.
>>and the other option is to inherit the textbox and make it a property of
the textbox.

Yes, that's yet another way to track the changes. :)

Pete
May 9 '07 #9
On Tue, 08 May 2007 23:27:39 -0700, Michael C <no****@nospam.comwrote:
That is possible although a poorer solution in most cases. Either way he
still needs to decide what he actually wants to do and then decide how to
store the data as *seperate* issues.
Yes, I agree (and said as much :) )
May 9 '07 #10

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

Similar topics

11
by: Mark | last post by:
Hi, For the last 2 years I've been developing vehicle tracking/telemetric software for a company as a self employed individual. The project is quiet big, and is going to be there flagship...
3
by: Sigmathaar | last post by:
Hi, I'm need some advice about lists and vectors. I'm doing a program who needs to have sequential access of a non ordered unit of objects whose size decreases almost each time the sequence is...
4
by: Web_PDE_Eric | last post by:
I don't know where to go, or what to buy, so plz re-direct me if I'm in the wrong place. I want to do high performance integration of partial differential eqns in n dimensions (n=0,1,2,3..etc) I...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
12
by: johannblake | last post by:
First off, I am NOT a beginner. I have lots of experience developing professional web sites and am a professional software developer. Unfortunately I've been out of web site development for the...
13
by: Alan Silver | last post by:
Hello, MSDN (amongst other places) is full of helpful advice on ways to do data access, but they all seem geared to wards enterprise applications. Maybe I'm in a minority, but I don't have those...
7
by: John Paul | last post by:
I'm thinking of building an e-commerce site in php. Anyone got any advice in building one? What is the best way to implement a payment system? Are any legal issues involved? Thanks,
7
by: Gladen Blackshield | last post by:
Hello All! Still very new to PHP and I was wondering about the easiest and simplest way to go about doing something for a project I am working on. I would simply like advice on what I'm asking...
2
by: jon121970 | last post by:
I'm new here.. I am hoping to get some Professional Advice. I want to start my own online Auction. I anticipate it will grow into a high volume/high traffic online auction. I need some...
7
by: SM | last post by:
Hello, I have a index.php template (2 columns). The right columns contains a bunch of links (interviews, poems, etc...) The left columns contains the actual article. So if I click on a link on...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
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
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
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,...

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.