473,396 Members | 1,712 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.

How to access control in child form (MDI app)


Hi,

I'm just writing my first real c# application and I have a problem
when trying to access a control in a child form.

I am using an MDI application with a parent form called frmMain. In
this code I need to parse some files whose filenames are in an
arraylist. Since this parsing may take some time, I want to display a
child form named frmProgress (created as frmProgessBar) that will show
a ProgressBar and update it during processing.
In frmMain I have code that looks like this:

frmProgress frmProgressBar = new frmProgress ();
frmProgressBar.MdiParent = this;
frmProgressBar.Show ();

// need to set progressbar maximum and minimum here

foreach (string s in FilesArray)
{
// do processing of files here
// update progressbar value on each iteration.
}
Now, my question is: how can I access the actual ProgressBar control
in the child? (i.e. provide the code for the comments above). I can
access the child form methods such as Show but I don't know how I can
access the control methods so that I can set the maximum, minimum and
value of the ProgressBar control.

Can I somehow use frmProgressBar.Controls to access the ProgessBar or
is there a way to reference it using the progressbar name?

Thanks

Karl

Nov 17 '05 #1
2 4079
Hi Karl,

One way to do it is to write a public method in your frmProgress that will
increase or decrease the value of the bar.
That way you can access that method in your foreach loop like:

foreach (string s in FilesArray)
{
// do processing of files here
frmProgressBar.YourMethodHere();
}

Cheers,
Christiaan
"Karl" <ka*******@insidertech.co.uk> schreef in bericht
news:11**********************@g47g2000cwa.googlegr oups.com...

Hi,

I'm just writing my first real c# application and I have a problem
when trying to access a control in a child form.

I am using an MDI application with a parent form called frmMain. In
this code I need to parse some files whose filenames are in an
arraylist. Since this parsing may take some time, I want to display a
child form named frmProgress (created as frmProgessBar) that will show
a ProgressBar and update it during processing.
In frmMain I have code that looks like this:

frmProgress frmProgressBar = new frmProgress ();
frmProgressBar.MdiParent = this;
frmProgressBar.Show ();

// need to set progressbar maximum and minimum here

foreach (string s in FilesArray)
{
// do processing of files here
// update progressbar value on each iteration.
}
Now, my question is: how can I access the actual ProgressBar control
in the child? (i.e. provide the code for the comments above). I can
access the child form methods such as Show but I don't know how I can
access the control methods so that I can set the maximum, minimum and
value of the ProgressBar control.

Can I somehow use frmProgressBar.Controls to access the ProgessBar or
is there a way to reference it using the progressbar name?

Thanks

Karl

Nov 17 '05 #2

Thanks Christiaan, that works fine.

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
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...
6
by: Uncle_Albert | last post by:
Hi there, Trying to get to grips with MDI applications at the mo and having a bit of trouble with the basics. What I have at the mo is the parent form loading and immediately displaying a...
3
by: Lance | last post by:
I've noticed that controls that are contained in MDI child forms fail to raise MouseLeave events if the MDI child form's MdiParent property is set to Nothing (after it was set to an existing 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...
1
by: Mark Hoffy | last post by:
Hello, I have an MDI app. There are many child forms and they all have several things in common. They all have a Save button, a public variable boolNavigate, and they all have a TreeView...
13
by: Academic | last post by:
I have a MDI form, sometimes child forms and sometimes forms that are neither If I close the app the child forms closing and closed event happens followed by the Mdi form receiving the...
1
by: Mucker | last post by:
This could be a difficult one, so please bear with me. I've an assembly containing Delphi 2006.NET forms. A C# app, via reflection opens these forms . This works fine - I've a C# app, opening...
0
by: =?Utf-8?B?UnVieSBOYWRsZXI=?= | last post by:
Hi everyone, i am trying to set control on mdi form from mdi child: trying to set toolstrip on mdi parent (MDIMain) from child form doing this way on the child form: ToolStrip Tool =...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.