473,804 Members | 3,018 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1378
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.co m

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

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.c omwrote:
[...]
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(st ring text) {Text=OldText=t ext;}
public bool IsDirty {get{return Text!=OldText;} }
}
....
DeviceOption opt = new DeviceOption("a bc");
textbox1.DataBi ndings.Add("Tex t",opt,"Text ");
.....
foreach(DeviceO ption 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.c om...
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*********@nn owslpianmk.comw rote 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*********@nn owslpianmk.comw rote 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
2121
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 product. Since I had no other work at the time, I agreed to a low rate when I first started which was £100 a day. The project started small, so it was only going to be for a few months, and I badly needed the money. The project soon balooned into...
3
3179
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 finished (at the begining I have about 2500 objects in the unit, after the first acces I have 2499, then 2435, then 1720 and so on). The problem is that sometimes after a whole sequence the number of objects in the unit remains unchanged. After...
4
2855
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 want to do (fast) graphic output of the results. I used to use C. I want to upgrade my computer. Do I get dual core? Does C# support dual-core? Is C# as fast as the old C? Is there a new C? (or is C# the new version of C?) Is Visual Studio...
15
4649
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 communicate with a MySQL database table on a web server, from inside of my company's Access-VBA application. I know VBA pretty well but have never before needed to do this HTTP/XML/MySQL type functions.
12
1694
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 past 2 years but would like to get back into it. What I need is some advice to get me up-to-date on what is the best (or one of the best) ways of developing web sites and web applications. The following are my requirements: * Static web pages...
13
3120
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 sorts of clients. Mine are all small businesses whose sites will never reach those sorts of scales. I deal with businesses whose sites get maybe a few hundred visitors per day (some not even that much) and get no more than ten orders per day....
7
2064
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
2240
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 so I can go and learn it myself through doing (best way for me). I am building a card game as a learning-project as it involves many (to most of the) things that I would like to learn to do with PHP.
2
2706
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 Recommendations as to what platform and what is the best configuration this Auction should be designed in to handle high volume(i.e. Php or ASP or CGI, Mysql)? I've seen some other Auction scripts out there.. but I really don't know the best design for an...
7
2170
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 the right menu, the article shows on the left column. The links have an url that look like this: http://www.myweb/library/?doc=194uf7s39
0
10578
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
10332
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...
0
10077
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
9152
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...
1
7620
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6853
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3820
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2991
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.