473,508 Members | 2,241 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inherited form Name from Base

Is there any way to get the name of an inheriting object in the item it
is inheriting from? In my case I am looking for a way to get the name
of a form from its base.

For example

Public Class BaseForm
Public Overridable Sub Foo()
'Can I Get the name of the calling obect in here without
passing it?
End Sub
End Class

Public Class InheritedForm
Inherits BaseForm

Public Overrides Sub Foo()
mybase.Foo()
End Sub
End Class

Dec 18 '06 #1
3 1293
Maybe try:
MyBase.Name

Dec 18 '06 #2
ScottL wrote:
Is there any way to get the name of an inheriting object in the item it
is inheriting from?
Public Class BaseForm
Public Overridable Sub Foo()
' Name of the calling object?
Debug.Writeline( Me.Name ) ' "calling" class
Debug.Writeline( MyClass.Name ) ' /this/ class
End Sub
End Class

Public Class InheritedForm
Inherits BaseForm

Public Overrides Sub Foo()
MyBase.Foo()
End Sub
End Class
HTH,
Phill W.
Dec 19 '06 #3
I can think of some ugly ways to do it.

One way would be a

mustoverride function GetChildName as string

That way the inheriting class would have to define a function or property if
you prefer to return its name and the base could safely call GetChildName
inside Foo.
You could do the same with an interface if you chose.

I don't know of a quick and easy key word way to do it in VB.NET

"ScottL" <sc**********@gmail.comwrote in message
news:11**********************@j72g2000cwa.googlegr oups.com...
Is there any way to get the name of an inheriting object in the item it
is inheriting from? In my case I am looking for a way to get the name
of a form from its base.

For example

Public Class BaseForm
Public Overridable Sub Foo()
'Can I Get the name of the calling obect in here without
passing it?
End Sub
End Class

Public Class InheritedForm
Inherits BaseForm

Public Overrides Sub Foo()
mybase.Foo()
End Sub
End Class

Jan 2 '07 #4

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

Similar topics

8
3050
by: TS | last post by:
I am trying to get set a property of a control on the inherited class from base class. I imagine i have to use reflection, so could someone give me the code to do it? something like this?...
10
2118
by: Chad Miller | last post by:
I currently have a base form that I inherit. The base for has a custom event. The event will not raise threw the inherited form. I was wondering if events work threw inheritance or should I use...
13
2205
by: Lorne Smith | last post by:
Hi, First, sorry for the crosspost, but it seemed appropriate... :) I've come accross what I consider to be a bug, but I don't know if it's already known or not. (VS .Net 2003 Pro - VB.Net) ...
8
6674
by: Spam Trap | last post by:
I am getting strange resizing problems when using an inherited form. Controls are moving themselves seemingly randomly, but reproducibly. "frmBase" is my base class (a windows form), and...
1
2039
by: skootr | last post by:
I have a Public Interface defined in a class module. I also have a form that implements that interface After building the solution, I added an Inherited Form (inherited from the above-mentioned...
4
2643
by: JC Voon | last post by:
Hi: My base form has a button, when click it will call MessageBox.Show( "Base form" ). I inherite a child form from the base and assign a button click event to the same button which will call...
4
3735
by: dbuchanan | last post by:
Is the following behavior normal? Both the 'Protected sub' in the inherited form and the 'Private Shadows sub' in the derived form fires. My interpretation of MSDN help on the topic "Shadows"...
4
1937
by: asad.naeem | last post by:
hi to all this is the problem about inheritence. I have designed a form with some essential controls which are required for every form which will inherited from it. for example i have Button1 on...
4
3489
by: EmilH | last post by:
Hi. I couldn't find it in msdn. I have a form AddCategory. Now I need EditCategory form which should look exactlay like AddCategory. I add an inherited form to the project. Now all controls'...
19
2209
by: jan.loucka | last post by:
Hi, We're building a mapping application and inside we're using open source dll called MapServer. This dll uses object model that has quite a few classes. In our app we however need to little bit...
0
7326
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
7383
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...
1
7046
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
7498
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
5627
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,...
0
4707
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...
0
3194
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...
0
1557
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 ...
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.