473,803 Members | 3,463 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4106
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*******@insi dertech.co.uk> schreef in bericht
news:11******** **************@ g47g2000cwa.goo glegroups.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
4763
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 appreciated. Thanks in advance
3
9710
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 parent menu functions. if i select draw line in MDI parent, the line should be drawn in current active child..any URLS for this or guide me to achieve this communication... -- Mähésh Kumär. R
6
1542
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 child form, which is to be used to log in to the system (username and password entry). When the user clicks connect on the child form, I want the menu's on the parent to become enabled.
3
3216
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 container form) or if the MDI child form's Visible property is set to False (after the MDI child form was shown). This is an enormous problem for my app because I must show different MDI child forms based on the state of my application and many of the...
10
4030
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 application. What should happen, is that the main MDI form should close, taking the child forms with it. There is code to loop through the child forms, remove the controls on each of them, and then close the form, but this code should execute only...
1
2735
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 called treeBrowse. I have a generic routine to create the TreeView and add it to a form since I do this on a dozen or so forms. I also would like to add event handlers in this generic routine. The handler routines perform the same function on...
13
2953
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 events.. But the regular forms that are also open do not receive that event. This is true whether there are child forms open or not.
1
4630
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 Delphi 2006.NET forms. Some of these forms are MDI Child forms. Exceptions are thrown - "Cannot create form - No MDI Forms are currently active" when the C# app tries to open one of these.
0
1537
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 = ((MDIMain)this.MdiParent).toolStrip; Tool.Enabled = false; or this way ((MDIMain)this.MdiParent).toolStrip.Enabled = false;
0
9703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10548
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10316
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10295
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7604
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6842
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5500
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4275
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.