473,699 Members | 2,539 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with enable/disable save button

Hi, can anyone help? I am fairly new to C# and need help with a
functionlity in my app. What I need to accomplish is to be able to enable
the SAVE button as soon as the user modifies a data in the form. Data
could be in a datagridview or textbox. All data are connected to the
tables/dataset. What is the easiest way to do this?

Thank you.

Aug 4 '06 #1
3 4598
Hehe, forgot to say that the SAVE button should be disabled after it was
clicked. Other buttons are affected by this too. CANCEL button will have
to follow the state of the SAVE button.

Thanks,

"Rick Shaw" <ri************ *****@hotmail.c omwrote in message
news:%2******** **********@TK2M SFTNGP03.phx.gb l...
Hi, can anyone help? I am fairly new to C# and need help with a
functionlity in my app. What I need to accomplish is to be able to enable
the SAVE button as soon as the user modifies a data in the form. Data
could be in a datagridview or textbox. All data are connected to the
tables/dataset. What is the easiest way to do this?

Thank you.

Aug 4 '06 #2
Typically, this is done by using a boolean field in the form which is
called, for example, "Dirty." It is initialized to false. In your case, you
might also want to use a Property, so that when you set the value, it can
change the state of the Save button at the same time. Example:

private bool _Dirty = false;
public bool Dirty
{
get { return _Dirty; }
set { btnSave.Enabled =_Dirty = value; }
}

Then you use an event handler for each Control that can affect the Dirty
value. How this is done depends on the Control. For a combobox, the
SelectedIndexCh anged event will do the trick. For a TextBox, the TextChanged
event will work. And so on. The handlers for these events should set the
Dirty property to true. The only time the Dirty property is set to false is
when the Form is initialized.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

Who is Mighty Abbott? A twin-turret scalawag.

"Rick Shaw" <ri************ *****@hotmail.c omwrote in message
news:%2******** **********@TK2M SFTNGP03.phx.gb l...
Hi, can anyone help? I am fairly new to C# and need help with a
functionlity in my app. What I need to accomplish is to be able to enable
the SAVE button as soon as the user modifies a data in the form. Data
could be in a datagridview or textbox. All data are connected to the
tables/dataset. What is the easiest way to do this?

Thank you.

Aug 4 '06 #3
Hi Kevin. Thanks for the quick reply.

Anyway, I was thinking that if I check the data change at the dataset level,
that will be better. With that, I have a question.

Is there a way to know about the change as soon as the user type or modify
someting, say in a gridview, even before pressing enter or tabbing out of
the cell?

Please advise.

Thank you.

Rick..
"Kevin Spencer" <uc*@ftc.govwro te in message
news:ue******** ********@TK2MSF TNGP04.phx.gbl. ..
Typically, this is done by using a boolean field in the form which is
called, for example, "Dirty." It is initialized to false. In your case,
you
might also want to use a Property, so that when you set the value, it can
change the state of the Save button at the same time. Example:

private bool _Dirty = false;
public bool Dirty
{
get { return _Dirty; }
set { btnSave.Enabled =_Dirty = value; }
}

Then you use an event handler for each Control that can affect the Dirty
value. How this is done depends on the Control. For a combobox, the
SelectedIndexCh anged event will do the trick. For a TextBox, the
TextChanged
event will work. And so on. The handlers for these events should set the
Dirty property to true. The only time the Dirty property is set to false
is
when the Form is initialized.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

Who is Mighty Abbott? A twin-turret scalawag.

"Rick Shaw" <ri************ *****@hotmail.c omwrote in message
news:%2******** **********@TK2M SFTNGP03.phx.gb l...
Hi, can anyone help? I am fairly new to C# and need help with a
functionlity in my app. What I need to accomplish is to be able to
enable
the SAVE button as soon as the user modifies a data in the form. Data
could be in a datagridview or textbox. All data are connected to the
tables/dataset. What is the easiest way to do this?

Thank you.



Aug 8 '06 #4

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

Similar topics

1
2714
by: Selen | last post by:
How can I disable save button in Word Documents from asp.net c#..... And I am saving Word documet to sql server database (Blob-image field)How can I undersatand when user open the document from database and change it?When user change it I save it another image field ... Thank you....
2
8903
by: RootSpy2006 | last post by:
Hi All, Problem Definition: --------------------- Microsoft Wirelss Keyboard works in BIOS but does not work when booting into windows. Discovered Work-around: ----------------------------- 1.> Open Device Manager(The keyboard device will have an exclamation and
3
7108
by: James | last post by:
Hello, I am having a problem with a MS Access 2000 Database that I partially helped create. I am recording visits that registered customers make to our store. I have a list of all the elidgible people that can shop, and when I click a button, it records a visit for today in Date/Time format. My problem is that the button that records the visit can be clicked multiple times, and I am trying to find a way to lock it for a few seconds so...
0
1404
by: ArmyGeek | last post by:
Hey Guys, Im trying to figure out how to Disable a Button after a user clicks it, then Enable the Button if the user emptys a Text Box where the user can input information. I also want to automaticaly Enable the Button and clear the Text Box if the user doesn't do anything for a specified amount of time after clicking the Button. Any Help with this would be appreciated. Thanks
2
6602
by: ArmyGeek | last post by:
Hey Guys, Im trying to figure out how to Disable a Button after a user clicks it, then Enable the Button if the user emptys a Text Box where the user can input information. I also want to automaticaly Enable the Button and clear the Text Box if the user doesn't do anything for a specified amount of time after clicking the Button. Any Help with this would be appreciated. Thanks
1
10644
by: elLiven | last post by:
Hi I'm trying to learn VBA in Excel mysel. Getting stuck on userforms. I can create a userform with optionbuttons and command buttons. I want to know how to have the form display the command button as inactive until an optionbutton is ticked and then becomes active?
3
4531
by: KMEscherich | last post by:
Hi there, I have a Save REQUIRED fields button and when all required fields have been filled in, the Save REQUIRED fields button becomes enabled. I have created a DATE field so that when the button is pressed, it gives me a date and time when they pressed it. Is there a way to disable this button once someone presses it? Thank you for your assistance.
5
11821
by: andersond | last post by:
I need to enable or disable a submit button based on the value of a data field stored in a database. I have found working examples of how to enable or disable based on a checkbox; but, I need it to work based on a data field value. I have created a textbox in a hidden area that contains the stored data value. I have set the beginning value of the submit button to disabled. I want the submit button to be enabled if the value in the textbox is...
2
2593
by: jbaptist | last post by:
I have 2 buttons on the form, Button A and button B. I want to enable button A from 6am till 6pm from Monday to Friday and to disable button B during 6am until 6pm. And I want to disable button A from 6.01pm till 11.59pm. During saturday, only button B is enabled for the whole day. CAN YOU PLS HELP BECAUSE I CANT GET THE CODING RIGHT.
0
8615
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9034
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
7750
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
6534
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
5874
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
4376
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
4629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2347
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2009
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.