![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
|
Another proublem...
Form1 is the main window. Has a drop down menu. When the bottom item is selected ("Add item") it opens a new form (well call it Form2). When form2 is closed I want it to refresh the list. I already have a function (or is it called a method?) for that. The only proublem is, it wont run it. The debug doesn't give me any error and there is no runtime error. Modifier is public so thats not the proublem eather.
Form1 = index, Form2 = addItem Ran at the end of addItem... public void resetCancle(string foc)
{
InputName.Enabled = true;
InputName.Text = "";
createProgress.Visible = false;
index mainSet = new index();
mainSet.fillProjs();
mainSet.comboBox1.SelectedText = foc;
this.Hide();
} |
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 915
Rep Power: 4
![]() |
I think the problem is this line
index mainSet = new index(); What you need to do is somehow get a hold of the original index form. This may be through the "Parent" member (if you have one - there is not enough of your code to know). Alternatively you could set a parent object into a member variabl of your addItem form when you create it. |
|
|
|
|
|
#3 | |
|
Hobbyist Programmer
|
I tried useing parent, the proublem is that it wouldent let me run any or the methods.
Quote:
|
|
|
|
|
|
|
#4 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 915
Rep Power: 4
![]() |
You could do something like:
In the addItem form add a public variable public index mainSet = null;; public void resetCancle(string foc)
{
InputName.Enabled = true;
InputName.Text = "";
createProgress.Visible = false;
if (mainSet != null)
{
mainSet.fillProjs();
mainSet.comboBox1.SelectedText = foc;
}
this.Hide();
}addItem myForm = new addItem(); myForm.mainSet = this; Please note: I am not an expert in C#, so there are probably better ways of doing this. |
|
|
|
|
|
#5 |
|
Hobbyist Programmer
|
Sweet, I'll let you know how it goes. After microsoft gets done attempting to destroy its own OS.
|
|
|
|
|
|
#6 |
|
Troll
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4
![]() |
Instead of having the forms reference each other, an improved design would be to have the addItem form have an event that is listened to by the index form that creates it. The index form should handle its own business.
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270 |
|
|
|
|
|
#7 |
|
Hobbyist Programmer
|
Example? I think I understand what you mean but I'm not 100% sure. I do like the idea of the index running its own processes though. Just not sure how to install a listener for when the child (addItem) runs hide().
|
|
|
|
|
|
#8 |
|
Hobbyist Programmer
|
Well for this project I'm not going to worry about the hide event. The solution "The Dark" gave works perfectly, Thank You!
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|