473,396 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Using Child Functions from a Parent form

I am using:
private void New_Click(object sender, EventArgs e)
{
f = new ChildForm();
f.MdiParent = this;
f.Text = "Form - " + this.MdiChildren.Length.ToString();
f.frm1=this;
f.Show();
}

to create child windows in a MDI container. In the child form I have:

public void eraseWindow()
{
foreach (DictionaryEntry myDE in roomList)
{
Rooms foundRoom = (Rooms)roomList[Convert.ToInt32(myDE.Key)];
if (foundRoom.ShowRoom)
{
foundRoom.ShowRoom=false;
foundRoom.ThisButton.Hide();
}
}
MessageBox.Show(Convert.ToString(roomList.Count));
}

This just loops through the buttons on the child form and hides them all...

In the main form I want it that when you click on the menu EDIT, then CLEAR FORM it will run this function for the child form. Is there any way to do that?

I have tried (in the parentform)

void DeleteRoomToolStripMenuItemClick(object sender, EventArgs e)
{
f.eraseWindow();
f.redrawWindow();
}

f is the name of the childForm. But I get an error on it.

Any and all help would be GREAT!
Thanks in advance.

Rob
Apr 5 '07 #1
1 880
I was trying to get creative and even tried this in the parent form instead of it being in the child form (with a few modifications)

void DeleteRoomToolStripMenuItemClick(object sender, EventArgs e)
{
foreach (DictionaryEntry myDE in f.RoomList)
{
Rooms foundRoom = (Rooms)f.RoomList[Convert.ToInt32(myDE.Key)];
if (foundRoom.ShowRoom)
{
foundRoom.ShowRoom=false;
foundRoom.ThisButton.Hide();
}
}
MessageBox.Show(Convert.ToString(f.RoomList.Count) );
}


I am trying to pull the info from the child form but end up getting
Object reference not set to an instance of an object
Apr 5 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: Suzanne Vogel | last post by:
Hi, I've been trying to write a function to test whether one class is derived from another class. I am given only id's of the two classes. Therefore, direct use of template methods is not an...
8
by: CJack | last post by:
hy, I have an mdi application, i create a child form and I want to know when a button is pressed while that child form is loaded. I have this code: private void frmTestBaby_KeyUp(object sender,...
3
by: Maheshkumar.R | last post by:
Hi groups, How i can command over the MDI CHIlD forms created dynamically at runtime from PARENT. Let say, i have generated 5 mdichild forms, but i want to work with child form1 from MDI...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
3
by: Zack Sessions | last post by:
I am using VB.NET 2003. I have read the threads concerning the problem where the FormStartPosition of CenterParent is ignored if the form is displayed with the Show method as opposed to the...
7
by: msxkim | last post by:
How to execute functions in the parent class first and then functions in the child class? For example, I have a parent class with functions 'ONE' and 'TWO' and child class has a function 'THREE'. ...
5
by: Rabia | last post by:
I am using the window.open() with modal=yes to simulate the pop up window as modalDialog in mozilla/firefox. The pop-up window (child) has a few options which the user selects and then click the...
14
by: ml_sauls | last post by:
I've built a system to enter and manage purchase orders. This is in use by >10 clients. Some use it in Access 97, most are in A2k. About half use it through a Citrix implementation. It is...
3
by: zacks | last post by:
Forgive me if this has been already asked an answered, I did do a search both here and in VS2005 Help, but I can't find the answer to my question. I am developing an MDI application that is a...
61
by: Sanders Kaufman | last post by:
I'm wondering if I'm doing this right, as far as using another class object as a PHP class property. class my_baseclass { var $Database; var $ErrorMessage; var $TableName; var $RecordSet;...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.