OK, the parent form displays several buttons, all of which are populated with text during the LoadButton() routine, using a foreach loop. The idea is that by clicking a button, a child window is displayed with all the information that the button links to. The child form is editable, and when it's closed the parent form updates so that the button has new information on it.
Essentially the parent form is supposed to look like a bunch...
					
					
						User Profile
				
					Collapse
				
			
		
	- 
	
	
	
	
 - 
	
	
	
	
OK, I think what I'm trying to do is remove the EventHandler once the child form has been called.
Having run a foreach loop and assigning each *bttn* individually, the bttn.Click += new EventHandler(Ca llButtonView); statement adds a new event when a button is clicked. How do I go about clearing that event? Do I have a bttn.Clicked -= new EventHandler(Ca llButtonView); immediately afterwards? Would that work?Leave a comment:
 - 
	
	
	
	
Multiple windows forms being called.. why?
Hi, I'd appreciate someone taking a look at this as I can't see what's going on. I have a parent form populated with buttons, when a button is clicked a new form opens via ShowDialog. When I close the child form the parent form updates, and when I click a button the second time the child form spawns twice, but the second one is only opened when the first is closed. Every time the parent is refreshed a duplicate is "primed" to appear the... - 
	
	
	
	
Hi Gary - this makes more sense now, and (perhaps unsurprisingly) everything now works perfectly! Many, many thanks!
HowardLeave a comment:
 - 
	
	
	
	
Hi, yeah, sorry it's abridged, just to give you a feel. Foreach is closed, and the counter is inside the block. Instead of tidying it up I've made it more confusing!
So: By moving the code to a separate method I can only call it from ParentForm_Load () rather than another class, unless I make it a public static void method. And when I make it static, I get the message:
Error 3 An object reference is required for the non-static...Leave a comment:
 - 
	
	
	
	
Hi Gary, I've tried to re-run the populating routine separately but I've come up with another problem, still related. The issue may be due to drawing the form in visual c# then writing the code separately. The code I have starts out as:
...Code:private void ParentForm_Load(object sender, EventArgs e) { int ButtonCount = 0; // a counter, nothing more Routines.BuildCurrentDatabase();Leave a comment:
 - 
	
	
	
	
Hi Gary, thanks once again. I think I understand now, so I'll give this a try.
Thanks for your time, I'll let you know how I get on.
HowardLeave a comment:
 - 
	
	
	
	
Hi, thanks. I'm not sure this is what I want, as I say I'm rather new to this and I don't want a messagebox particularly, I want the entire parent form to be refreshed, redrawn, reloaded, whatever it is.
Basically, if the child form changes a parameter from "X" to "Y", when that child form is closed I want the parent to express that change directly, not via a messagebox. I have the code in place to have the parent...Leave a comment:
 - 
	
	
	
	
Refreshing a parent form
Hi,
I'm a new programmer, and have a small problem. I've been trying to get a form populated with lots of buttons and tabs to be refreshed when its child form is closed. The routine I have is this:
If I understand correctly, the parent form code should pause until NewForm_View is Closed (or should...Code:NewForm_View show_it = new NewForm_View(); show_it.ShowDialog(); Form.ActiveForm.Refresh();
 
No activity results to display
							Show More
							
Leave a comment: