i have a custom control that gets loaded at runtime. i need to be
able to access a property of a control thats part of the main form,
through the clcik event of the custom control.
i may be making this harder than it needs to be, but seem to be
buffaloed at this point.
thanks to all....
-
john 6 2324
"forest demon" <me********@gma il.comwrote in message
news:11******** **************@ e9g2000prf.goog legroups.com...
>i have a custom control that gets loaded at runtime. i need to be
able to access a property of a control thats part of the main form,
through the clcik event of the custom control.
i may be making this harder than it needs to be, but seem to be
buffaloed at this point.
thanks to all....
-
john
1.) The control you want to access from the user control needs to be visible
to the usercontrol by making the control public or internal.
2.) In the user control's code, you would use the FindForm method (instance
member of Control) and cast the result to the main form's type. (FindForm
returns a reference to the form the control is a child of).
3.) You access the control by name/id on the main form's reference (since
it's a visible member of the main form).
HTH,
Mythran
John,
If the control on the main form is exposed as a public member (or
internal, if they are in the same assembly), then you can just call Parent
on the child control, and cast it to an instance of the parent form and
access the member.
If not, then you have to expose a method/property/field on the parent
form to expose the control you want.
Either that, or you have to pass this information to the control
somehow, either by setting a property, field, or calling a method.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"forest demon" <me********@gma il.comwrote in message
news:11******** **************@ e9g2000prf.goog legroups.com...
>i have a custom control that gets loaded at runtime. i need to be
able to access a property of a control thats part of the main form,
through the clcik event of the custom control.
i may be making this harder than it needs to be, but seem to be
buffaloed at this point.
thanks to all....
-
john
"forest demon" <me********@gma il.comwrote in message
news:11******** **************@ e9g2000prf.goog legroups.com...
>i have a custom control that gets loaded at runtime. i need to be
able to access a property of a control thats part of the main form,
through the clcik event of the custom control.
i may be making this harder than it needs to be, but seem to be
buffaloed at this point.
It sounds to me as if you have inversion of control issues and overcoupling.
A custom control is concerned with its own drawing, properties, etc. A
custom control is not concerned with making the parent form function
correctly.
Declare a public event on the custom control, write a handler in the parent
form. That's the appropriate place to handle interaction between controls.
You can implement an interface, such as IServiceProvide r in the form class.
Later in the user control you can query the interface from the parent form.
--
Sheng Jiang
Microsoft MVP in VC++
"forest demon" <me********@gma il.comwrote in message
news:11******** **************@ e9g2000prf.goog legroups.com...
i have a custom control that gets loaded at runtime. i need to be
able to access a property of a control thats part of the main form,
through the clcik event of the custom control.
i may be making this harder than it needs to be, but seem to be
buffaloed at this point.
thanks to all....
-
john
"forest demon" <me********@gma il.comwrote in message
news:11******** **************@ e9g2000prf.goog legroups.com...
>i have a custom control that gets loaded at runtime. i need to be
able to access a property of a control thats part of the main form,
through the clcik event of the custom control.
i may be making this harder than it needs to be, but seem to be
buffaloed at this point.
thanks to all....
-
john
Use System.Manageme nt and read the "WindowsDirecto ry" property of WMI's
class Win32_Operating System.
Next sample reads the "windowsdirecto ry" from a remote server (BOBSMachine)
....
ConnectionOptio ns co = new ConnectionOptio ns();;
co.Username = "administrator" ; // user with sufficient privileges to
connect to the cimv2 namespace
co.Password = "adminPwd"; // his password
ManagementScope scope = new
ManagementScope (@"\\BOBSMachin e\root\cimv2", co);
SelectQuery query =
new SelectQuery("Se lect windowsdirector y from
Win32_Operating System");
ManagementObjec tSearcher searcher =
new ManagementObjec tSearcher(scope , query);
foreach (ManagementObje ct windir in searcher.Get())
Console.WriteLi ne("Value = {0}", windir["windowsdirecto ry"]);
....
Willy.
"Willy Denoyette [MVP]" <wi************ *@telenet.bewro te in message
news:eo******** ******@TK2MSFTN GP03.phx.gbl...
"forest demon" <me********@gma il.comwrote in message
news:11******** **************@ e9g2000prf.goog legroups.com...
>>i have a custom control that gets loaded at runtime. i need to be able to access a property of a control thats part of the main form, through the clcik event of the custom control.
i may be making this harder than it needs to be, but seem to be buffaloed at this point.
thanks to all....
- john
Use System.Manageme nt and read the "WindowsDirecto ry" property of WMI's
class Win32_Operating System.
Next sample reads the "windowsdirecto ry" from a remote server
(BOBSMachine)
...
ConnectionOptio ns co = new ConnectionOptio ns();;
co.Username = "administrator" ; // user with sufficient privileges to
connect to the cimv2 namespace
co.Password = "adminPwd"; // his password
ManagementScope scope = new
ManagementScope (@"\\BOBSMachin e\root\cimv2", co);
SelectQuery query =
new SelectQuery("Se lect windowsdirector y from
Win32_Operating System");
ManagementObjec tSearcher searcher =
new ManagementObjec tSearcher(scope , query);
foreach (ManagementObje ct windir in searcher.Get())
Console.WriteLi ne("Value = {0}", windir["windowsdirecto ry"]);
...
Willy.
Sorry, wrong thread, please ignore previous reply .
Willy. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Yannick Turgeon |
last post by:
Hello,
We are in the process of examining our current main application. We have to
do some major changes and, in the process, are questionning/validating the
use of MS Access as front-end. The application is relatively big: around 200
tables, 200 forms and sub-forms, 150 queries and 150 repports, 5GB of data
(SQL Server 2000), 40 users.
I'm wondering what are the disadvantages of using Access as front-end? Other
that it's not...
|
by: TD |
last post by:
This is the code under a command button -
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.BackColor <> RGB(255, 255, 255) Then
ctl.BackColor = RGB(255, 255, 255)
End If
Next ctl
|
by: BBFrost |
last post by:
We have a data entry application written within Framework 1.0 that contains
20+ custom user controls.
The controls overlay each other so that only one custom control is visible
at a time. What is the best way to keep the cursor from jumping to another
non-visible control when the user tabs past the (currently designated) last
control on the form. I've had some luck using the Leave event but the last
visible control can change...
|
by: John J. Hughes II |
last post by:
I have a DataGridView displaying data from a DataSet. To the right of that
I have a custom user control which displays one of the data set fields.
The custom user control is bound to the data set object and displays the
data correctly when I move from row to row.
The problem I am having is the data set always reads the data back and
considers it change even when it's not. I am looking for how to change the
following code so the...
|
by: rizwanahmed24 |
last post by:
Hello
i have made a custom control. i have placed a panel on it. I want this
panel to behave just like the normal panel. The problem i was having is
that the panel on my custom control doesnt accept other controls. The
control i drag drop on it becomes the child of my custom control's
parent form and not the child of my custom control. Then i added this
line
""
before my custom control class (i dont know what this line does). Now
| |
by: ahmed.maryam |
last post by:
Hello Everyone,
I designed a custom control that is entirely covered by a picture box.
I then dragged this custom control onto a windows form application
(called main) and I need to handle mouse events in my main
application. Specifically, when a user double clicks on my custom
control I need to draw something on another picture box located in my
main application.
I'm going to attempt to draw the scenario because I think it will
|
by: ChopStickr |
last post by:
I have a custom control that is embedded (using the object tag) in an html document.
The control takes a path to a local client ini file.
Reads the file.
Executes the program specified in the ini on the client's PC.
After the program has ended the control looks in a client side temp folder (specified by the ini file) for an image created by the executed program.
If the image is there, then the control moves the file to a public folder...
|
by: hyperpau |
last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding.
I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com).
Ergo, I will be writing this article intended for those who are in the same level, or maybe lower, of my technical knowledge.
I would be using layman's words, or maybe, my own words as how I understand them, hoping, you will understand it the same way that...
|
by: =?Utf-8?B?UmljaEI=?= |
last post by:
I am trying to create a project using the ASP.NET AJAX accordion control. I
would like to dynamically add panes to the control with a form template added
when the pane is added. I have tried unsuccessfully in creating the whole
pane as a user control and have succeeded in adding the pane and then
dynamically adding the content which is a user control to the pane,
dynamically within the page.
However I would like to have a single pane...
|
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...
|
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...
| |
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...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
| |