Detect changes on form

C

Christian Pické

Hi,

I am using a Windows Form with mostly textboxes and comboboxes on it.

To detect if the 'record' has been modified by the user, I am using the
TextChanged event of each textbox, where I set a boolean to true. That way I
can ask the user if he likes to save the data when het exits the form.

Question: is there a faster way to detect that the content of any control on
a form has been modified (like the event AfterUpdate in MS Access)? I know
that it is possible with bound controls, but in this concept I work with
unbound controls which are filled and/or saved by stored procedures.

Thanks in advance,

Christian
 
W

William Ryan

If you aren't using Bound Controls, I think you are going to have to wing it
as far as detecting if something is changed....check each control and set
the a dirty flag of some sort. You could use the same event handler for
each of the text boxes, by adding , Handles textbox2.textChnaged ,
textbox2.textChanged etc, this would save you from writing all that code by
hand, then one event handler could be used for all of the textboxes.

However, and this is just my two cents....I have worked with someone who
refuses to use DataBindings and bound controls. Basically, each time the
user selected a different value in a list box, he'd make a trip to the
Database and populate each of the controls manually. He argued that it was
much less work doing it this way and all you need to do is write a function
or two and everything is fine. Little by little, this methodology has
caused maintenance headaches....and that's not to mention that you are
hitting the DB much more than necessary..for instance, if the user clicks on
the wrong item and clicks back, that just caused a trip to the db. For what
it's worth, you can still use Stored Procs (actually is the best method) and
the like in conjunction with your DataBindings and save yourself a lot of
headaches not to mention reduce a lot of unnecessary headaches. However, if
you must requery, I think wiring everythign to one event handler will save
you some work.

HTH,

Bill
 
C

Christian Pické

Dear William,

I know but I am a confused about the method I should use. Let me explain.

I have a good working POS & CRM application that I am selling since 1998 in
Belgium, with tons of on the flee information. For example if you select a
customer, you can see what he bought, unpaid invoices, open offers,
backorders, turnover statistics and much more, .... but all this information
make s the application too slow. It has been written in MS Access and speed
is on the limit to be acceptable. In Access I work with bound controls and I
would LOVE to do it the same way in .NET, but I am afraid (for performance
reasons) of loading a whole dataset (I have customers with > 14000 customers
and one with 136000 products). And I want to keep strictly to the Three Tier
programming technique and, indeed, I work with Stored Procedures.
So what I am doing right now is:
I show the customer form when a user is requesting customer data and I call
a stored procedure, read the data for only ONE record and store the field
contents in an unbound control. Of course, showing statistics, unpaid
invoices, ... still requires calculating and loading information, but for
one customer at a time. In Access, the whole thing was retrieved from the
database (since I was using SubForms) and that is very timeconsuming (it
takes me between 4 and 10 seconds to navigate between customer records; it
takes > 20 seconds to load and display a customer form).
I must say performance is fantastic by using unbound controls in .NET!!!
I have the feeling that getting the whole dataset is putting me in the old
situation, and the only two reasons for migrating to .NET is performance and
a better way to do the setup and maintanance.

Or do you mean I should use a limited dataset by using SELECT * FROM
Customer WHERE CustomerID = .....and make do some profit this way by using
it with bound controls?

Any advice would be appeciated!!!

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top