This seems like a dumb question, but here goes: In my own VB.NET user
control, how do I gain access to the user controls parent? (i.e. the form
that is hosting the user control) For instance, in the control I want to set
the focus back to the main form that has the user control. Most other
classes/controls seem to have a Parent but not a user control.
I could, of course, pass a reference of the main form to the user control,
but this seems like overkill. Any other way? Thanks....
Tom 6 16410
"Tom" <to*@nospam.com> wrote in message
news:e2**************@TK2MSFTNGP14.phx.gbl... In my own VB.NET user control, how do I gain access to the user controls parent?
Would you believe the [UserContrl].Parent property?
The FindForm() method will also get you the Form on which the
control appears, which is *not* necessarily the same thing.
HTH,
Phill W.
"Tom" <to*@nospam.com> schrieb: This seems like a dumb question, but here goes: In my own VB.NET user control, how do I gain access to the user controls parent? (i.e. the form that is hosting the user control) For instance, in the control I want to set the focus back to the main form that has the user control. Most other classes/controls seem to have a Parent but not a user control.
'UserControl' inherits from 'Control' and thus has a 'Parent' property and a
'FindForm' method. In addition to that, it has a 'Container' property.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Aha, this may explain it. I mis-spoke... This is a non-visual control, i.e.
a componet, so instead I inherit from System.ComponentModel.Component,
rather than user control.
So, there is probably no way to get the parent directly from here, is there?
Again, I want this to be a non-visual control (one that shows up in the
developer 'tray area' like a menu or image control does)...
Tom
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:O2**************@tk2msftngp13.phx.gbl... "Tom" <to*@nospam.com> schrieb: This seems like a dumb question, but here goes: In my own VB.NET user control, how do I gain access to the user controls parent? (i.e. the
form that is hosting the user control) For instance, in the control I want to set the focus back to the main form that has the user control. Most other classes/controls seem to have a Parent but not a user control. 'UserControl' inherits from 'Control' and thus has a 'Parent' property and
a 'FindForm' method. In addition to that, it has a 'Container' property.
-- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Phil: As I mentioned to Herfried:
Aha, this may explain it. I mis-spoke... This is a non-visual control, i.e.
a componet, so instead I inherit from System.ComponentModel.Component,
rather than user control.
So, there is probably no way to get the parent directly from here, is there?
Again, I want this to be a non-visual control (one that shows up in the
developer 'tray area' like a menu or image control does)...
Tom
"Phill. W" <P.A.Ward@o-p-e-n-.-a-c-.-u-k> wrote in message
news:cu**********@yarrow.open.ac.uk... "Tom" <to*@nospam.com> wrote in message news:e2**************@TK2MSFTNGP14.phx.gbl... In my own VB.NET user control, how do I gain access to the user controls parent?
Would you believe the [UserContrl].Parent property?
The FindForm() method will also get you the Form on which the control appears, which is *not* necessarily the same thing.
HTH, Phill W.
"Tom" <to*@nospam.com> schrieb: Aha, this may explain it. I mis-spoke... This is a non-visual control, i.e. a componet, so instead I inherit from System.ComponentModel.Component, rather than user control.
So, there is probably no way to get the parent directly from here, is there? Again, I want this to be a non-visual control (one that shows up in the developer 'tray area' like a menu or image control does)...
Components are typically placed in the components tray in VS.NET. You can
use a component's 'Container' property to get the container it resides in.
The components 'Site' property might be of interest too.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
I have the same problem, I have a form on which I drag a
self made component, it appears under the separater below the form.
When I call me.Container or me.Site in the component they return nothing
"Herfried K. Wagner [MVP]" wrote: "Tom" <to*@nospam.com> schrieb: Aha, this may explain it. I mis-spoke... This is a non-visual control, i.e. a componet, so instead I inherit from System.ComponentModel.Component, rather than user control.
So, there is probably no way to get the parent directly from here, is there? Again, I want this to be a non-visual control (one that shows up in the developer 'tray area' like a menu or image control does)...
Components are typically placed in the components tray in VS.NET. You can use a component's 'Container' property to get the container it resides in. The components 'Site' property might be of interest too.
-- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Marcel |
last post by:
Hello, Iīm trying to create a custom user control, but I didnīt wanted
to put it inside a form, I wanted it to an object by itīs own..
I first created my class derived from Form, set the style to...
|
by: Joe Fallon |
last post by:
What is the code to read a field value of the Parent Page from an embedded
User Control?
I can use reflection to get it, but I thought there would be an easier way.
--
Joe Fallon
|
by: Mat |
last post by:
Hi,
I am having a bit of a problem trying to access / set properties of a
usercontrol from the parent codebehind.
This is what I have so far..
simple.aspx
<%@ Page...
|
by: John A Grandy |
last post by:
Let's say I have an .aspx Page instance derived from class "MyPage" (which
of course inherits from System.Web.UI.Page).
On the .aspx Page , I have "uc1", an instance of a UserControl dervived...
|
by: lotus |
last post by:
HI All..
I'm realtively new to C#.
I have MainForm which includes Parent usercontol, and this parent
usercontrol also contains child usercontrol.
MainForm --> Parent usercontrol --> child...
|
by: Jimi |
last post by:
Hi all, I have a user control which I want to raise a custom event from so
the parent page can reload a datagrid with some new information.
In the 1.1 framework days I would have just done...
|
by: Steve Hershoff |
last post by:
I have two UserControls I'd like to have talk to each other. One of them is
contained within the other, in a parent/child relationship. The child
control is loaded dynamically (it's declared as a...
|
by: Martijn Mulder |
last post by:
I want my custom UserControl to size and resize with its parent, a Form. But
when I use the code
Size=Parent.ClientSize;
in the constructor of myUserControl, Parent is null and the operation...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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...
|
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
|
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...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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...
|
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,...
|
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...
| |