Click here to Skip to main content
15,867,594 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Currently, I am using a button to update cost results in a windows form but would rather not use the button anymore to update the total cost. It's repetitive to always click "Update" when I make a change in a radio button or a checkbox. I'm wondering if there is a way to use sub procedures to make changes dynamic so if I check or uncheck a checkbox, there is an automatic update. Could someone point me to the right direction? I'm not sure how to start coding.
Posted

1 solution

How about firing the textchanged event for the text box? http://msdn.microsoft.com/en-us/library/system.windows.forms.control.textchanged(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1[^]

Or the Click event for the checkbox.
 
Share this answer
 
Comments
21spirals 18-Dec-13 0:42am    
Ah, I hadn't thought of this. If I use a click event for the checkboxes, and a check event for the radio buttons, do I need to have every single control under its own event? I'm trying to understand how to do this without repeating if-then statements.
_Damian S_ 18-Dec-13 0:52am    
If it's the same code that gets fired, put the common code into a function/procedure and call that from each event - that way your code that actually does the work is in one location, but called from a variety of places.
21spirals 18-Dec-13 1:16am    
I'm going to sound dense but is there is example of how to structure this? I'm having trouble figuring out how to call the procedure when the calculations are initially based on a button click.
_Damian S_ 18-Dec-13 1:23am    
private sub Calculate()
' Check that fields are filled as required

' do fancy stuff

' update whatever
end sub

Then inside your click event, simply call "Calculate()".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900