Cleariing controls on a form...

B

Brad Pears

I am working on a contract generation application for our log home business.

I have a main form that has many controls on it including tabbed controls,
panes etc...

When the user decides they want to do a new contract, they can click the
"New" button and I will save any changes (if any) - then I want to clear the
form to be ready for them to enter a new contract.

Is there some easy mothod to clear controls on a form - or do I just have
to basically do it manually? I know I can loop through controls on a form
and do it that way but is there not any easier way at all?

Thanks, Brad
 
R

rowe_newsgroups

I am working on a contract generation application for our log home business.

I have a main form that has many controls on it including tabbed controls,
panes etc...

When the user decides they want to do a new contract, they can click the
"New" button and I will save any changes (if any) - then I want to clear the
form to be ready for them to enter a new contract.

Is there some easy mothod to clear controls on a form - or do I just have
to basically do it manually? I know I can loop through controls on a form
and do it that way but is there not any easier way at all?

Thanks, Brad

I would say the most performant way would be to write a recursive
function that loops through all the controls and resets the text
property.

Thanks,

Seth Rowe
 
R

rowe_newsgroups

I am working on a contract generation application for our log home business.

I have a main form that has many controls on it including tabbed controls,
panes etc...

When the user decides they want to do a new contract, they can click the
"New" button and I will save any changes (if any) - then I want to clear the
form to be ready for them to enter a new contract.

Is there some easy mothod to clear controls on a form - or do I just have
to basically do it manually? I know I can loop through controls on a form
and do it that way but is there not any easier way at all?

Thanks, Brad

Oh, I meant to say you also could put all the controls into a seperate
usercontrol which you add to the form. Then when you want to clear all
the fields you could load a new instance of the usercontrol, add it to
the form, and then remove and dispose of the previous instance of the
usercontrol. That should reset all the fields to the designer set
defaults.

Thanks,

Seth Rowe
 
B

Brad Pears

Hi there... Thanks for that very interesting approach. It sounds
interesting. Could you possibly elaborate a bit on that idea??

What might the separate user control actually be?

Any sample code would be appreciated...

Thanks, Brad
 
R

rowe_newsgroups

Hi there... Thanks for that very interesting approach. It sounds
interesting. Could you possibly elaborate a bit on that idea??

What might the separate user control actually be?

Any sample code would be appreciated...

Thanks, Brad

The user control would contain any of the controls you want to reset.
It's very simple to create - just copy and paste all the controls and
code-behind into a new user control. Once you add this usercontrol to
your form you can just look at the designer created code to get the
property values that you set in the designer. Then just recreate the
control with these properties when you want to reset the control
values.

Thanks,

Seth Rowe
 
B

Brad Pears

Ok, I will give that a shot... Thanks for your help...
I may ask more questions. :)

Brad
 
R

rowe_newsgroups

PS...

By new user control do you mean a new form class?







- Show quoted text -

No. I mean a UserControl. :)

Goto Project-->Add New Item and select "UserControl"

A UC is basically a control that holds controls, so you add and
program a UC just like you do a form. The main difference is that a UC
can not be run on it's own, it must first be added to a form.

Thanks,

Seth Rowe
 
B

Brad Pears

Got ya... Never heard of or used one before. That's why I was confused. Ok,
I will look into it! Thanks for that. I am a complete newbie to the vb.net
world in case you hadn't noticed! :)

Thanks, Brad
 

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