reseting forms
-
I did do a google search and looked at a few books but am stuck. I have a form that I want to reset the text boxes on: 1) reset the text boxes within the group box 2) reset the whole form tia! shwaguy
shwaguy wrote:
I did do a google search and looked at a few books but am stuck. I have a form that I want to reset the text boxes on: 1) reset the text boxes within the group box 2) reset the whole form
Excellent - now what have you done so far? How far have you got with your code - or were you wanting us to write the code for you?
Deja View - the feeling that you've seen this post before.
-
I did do a google search and looked at a few books but am stuck. I have a form that I want to reset the text boxes on: 1) reset the text boxes within the group box 2) reset the whole form tia! shwaguy
if you mean to reset the controls to its a default value for a property i.e Text you may follow this step 1. create list to buffer a property value for each controls in your form 2. get property value back to controls according its index sample
private ArrayList initialValues = new ArrayList();
private void StoreInitialValue()
{
foreach (Control ctl in YourForm.Controls)
{
initialValues.Add(ctl.property);
}private void ResetToInitialValue()
{
for (int i=0; i< YourForm.Controls.Count; i++)
{
YourForm.Controls[i].Property = (typeof(your.stored.property.type))initialValues[i];
}
}
}hope it helps
dhaim programming is a hobby that make some money as side effect :)
-
shwaguy wrote:
I did do a google search and looked at a few books but am stuck. I have a form that I want to reset the text boxes on: 1) reset the text boxes within the group box 2) reset the whole form
Excellent - now what have you done so far? How far have you got with your code - or were you wanting us to write the code for you?
Deja View - the feeling that you've seen this post before.
Thanks for the reply smart guy (AKA ass). Want a chance to redeem yourself? What I am asking is a newbie question and I have no idea how to go about reseting a whole group of textboxes. Questions I have asked myself: Is it possible? Is it a built in function of the MS C# IDE like "groupbox1.child.text = ""? looking for some help and not smart ass comments. tia shwaguy
-
if you mean to reset the controls to its a default value for a property i.e Text you may follow this step 1. create list to buffer a property value for each controls in your form 2. get property value back to controls according its index sample
private ArrayList initialValues = new ArrayList();
private void StoreInitialValue()
{
foreach (Control ctl in YourForm.Controls)
{
initialValues.Add(ctl.property);
}private void ResetToInitialValue()
{
for (int i=0; i< YourForm.Controls.Count; i++)
{
YourForm.Controls[i].Property = (typeof(your.stored.property.type))initialValues[i];
}
}
}hope it helps
dhaim programming is a hobby that make some money as side effect :)