473,378 Members | 1,391 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,378 software developers and data experts.

Problem using a getting the parent name of a control when using form inheritance

I want to show the parent name of a control in an addin I am writing.
However, when I use the following :

string parentName = thisControl.Parent.Name // thisControl is of type
Control

it is returning the name of the base type. Below is the form class
declaration:

public class frmUserEditor : VBUsers.Windows.Forms.EditorFormBase
{
....
}

ie. It returns the name of EditorFormBase rather than the name of
frmUserEditor.

Does anyone know why this is happening and how to get the name of the
most derived container of the control?

tia

andrew
Nov 16 '05 #1
2 1278
It's my guess that your parent form, EditorFormBase, has a set of controls
on it, and the control you are testing is one of them.
In this case, the behavior your are experiencing is expected.

You could always derive a control subclass that allows you to set a
typename. In the constructor for your form class, you can pass in the name
of the class, and assign that name to each of your controls, regardless of
where they are declared.

(just a suggestion)

Hope this helps,
--- Nick

"Andrew Baker" <we*******@vbusers.com> wrote in message
news:c1**************************@posting.google.c om...
I want to show the parent name of a control in an addin I am writing.
However, when I use the following :

string parentName = thisControl.Parent.Name // thisControl is of type
Control

it is returning the name of the base type. Below is the form class
declaration:

public class frmUserEditor : VBUsers.Windows.Forms.EditorFormBase
{
...
}

ie. It returns the name of EditorFormBase rather than the name of
frmUserEditor.

Does anyone know why this is happening and how to get the name of the
most derived container of the control?

tia

andrew

Nov 16 '05 #2
Thank Nick but that's not the case, they are only on the derived
form... Anyone else any ideas?

andrew
"Nick Malik" <ni*******@hotmail.nospam.com> wrote in message news:<SpW3d.233438$mD.108969@attbi_s02>...
It's my guess that your parent form, EditorFormBase, has a set of controls
on it, and the control you are testing is one of them.
In this case, the behavior your are experiencing is expected.

You could always derive a control subclass that allows you to set a
typename. In the constructor for your form class, you can pass in the name
of the class, and assign that name to each of your controls, regardless of
where they are declared.

(just a suggestion)

Hope this helps,
--- Nick

"Andrew Baker" <we*******@vbusers.com> wrote in message
news:c1**************************@posting.google.c om...
I want to show the parent name of a control in an addin I am writing.
However, when I use the following :

string parentName = thisControl.Parent.Name // thisControl is of type
Control

it is returning the name of the base type. Below is the form class
declaration:

public class frmUserEditor : VBUsers.Windows.Forms.EditorFormBase
{
...
}

ie. It returns the name of EditorFormBase rather than the name of
frmUserEditor.

Does anyone know why this is happening and how to get the name of the
most derived container of the control?

tia

andrew

Nov 16 '05 #3

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

Similar topics

3
by: DD | last post by:
I want to link a form to another form by a Cmd Button. CustomerID = CustomerID I want the form to open from the Cmd Button as if it was acting in the same way as subform What would be the code?...
0
by: Bruin | last post by:
Hi All, I'm having a problem with MDI child forms when the reference to the MDI Parent is set in a Control library. (Sorry for the long post) I have an control library assembly which holds all...
21
by: cmd | last post by:
I have code in the OnExit event of a control on a subform. The code works properly in this instance. If, however, I put the same code in the OnExit event of a control on a Tab Control of a main...
2
by: Jiwei06xie | last post by:
Hi All, I am trying to upgrade an Access 2000 DB to 2007 (using linked tables and ODBC to connect to backend SQL 2000 database). In my DB, I have a mainswitch board and some command buttons on it....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
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...

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.