Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Oct 16th, 2005, 11:50 PM   #1
bja888
Hobbyist Programmer
 
bja888's Avatar
 
Join Date: Oct 2005
Location: Central, FL
Posts: 213
Rep Power: 0 bja888 is an unknown quantity at this point
Send a message via AIM to bja888 Send a message via Yahoo to bja888
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();
}
bja888 is offline   Reply With Quote
Old Oct 17th, 2005, 4:01 AM   #2
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 915
Rep Power: 4 The Dark is on a distinguished road
I think the problem is this line
index mainSet = new index();
You are creating a new index form at this point and updating its list. The new form is never shown, so you don't getto see any updates.
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.
The Dark is online now   Reply With Quote
Old Oct 17th, 2005, 11:57 AM   #3
bja888
Hobbyist Programmer
 
bja888's Avatar
 
Join Date: Oct 2005
Location: Central, FL
Posts: 213
Rep Power: 0 bja888 is an unknown quantity at this point
Send a message via AIM to bja888 Send a message via Yahoo to bja888
I tried useing parent, the proublem is that it wouldent let me run any or the methods.
Quote:
Alternatively you could set a parent object into a member variabl of your addItem form when you create it.
How?
bja888 is offline   Reply With Quote
Old Oct 17th, 2005, 8:45 PM   #4
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 915
Rep Power: 4 The Dark is on a distinguished road
You could do something like:

In the addItem form add a public variable
   public index mainSet = null;;
Then you can use it in your resetcancle method
public void resetCancle(string foc)
{
  InputName.Enabled = true;
  InputName.Text = "";
  createProgress.Visible = false;
  if (mainSet != null)
  {
    mainSet.fillProjs();
    mainSet.comboBox1.SelectedText = foc;
  }
  this.Hide();
}
When you create the addItem form, just set the mainSet member variable to the parent form.
 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.
The Dark is online now   Reply With Quote
Old Oct 17th, 2005, 8:55 PM   #5
bja888
Hobbyist Programmer
 
bja888's Avatar
 
Join Date: Oct 2005
Location: Central, FL
Posts: 213
Rep Power: 0 bja888 is an unknown quantity at this point
Send a message via AIM to bja888 Send a message via Yahoo to bja888
Sweet, I'll let you know how it goes. After microsoft gets done attempting to destroy its own OS.
bja888 is offline   Reply With Quote
Old Oct 17th, 2005, 8:56 PM   #6
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
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
Dameon is offline   Reply With Quote
Old Oct 17th, 2005, 9:33 PM   #7
bja888
Hobbyist Programmer
 
bja888's Avatar
 
Join Date: Oct 2005
Location: Central, FL
Posts: 213
Rep Power: 0 bja888 is an unknown quantity at this point
Send a message via AIM to bja888 Send a message via Yahoo to bja888
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().
bja888 is offline   Reply With Quote
Old Oct 17th, 2005, 9:43 PM   #8
bja888
Hobbyist Programmer
 
bja888's Avatar
 
Join Date: Oct 2005
Location: Central, FL
Posts: 213
Rep Power: 0 bja888 is an unknown quantity at this point
Send a message via AIM to bja888 Send a message via Yahoo to bja888
Well for this project I'm not going to worry about the hide event. The solution "The Dark" gave works perfectly, Thank You!
bja888 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:15 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC