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

Sibling classes

Hi,

I have a "Sibling Classes" issue:

° I have some Classes (forms) all Subclassed from System.Windows.Forms.Form.

° I have Classes in which there is a Property "OwnerForm" (for Components).

That poperty must accept:

° System.Windows.Forms.Form
° Subclassed Form_A
° Subclassed Form_B
° Subclassed Form_B_X
° Subclassed Form_B_Z
° Subclassed Form_C

For the property to accept all those Sibling-Classes, I could put it's type to Object.
Checking the Type in the Set of the Property is no problem

BUT:

The property can also be set in Design-Time, so it's Available to the "Property-Browser" (<EditorBrowsable(EditorBrowsableState.Always), Browsable(True), ....)

And the last thing I want is a messy feeling being able to select "All kind of Objects".

THEREFORE:

Is there a way to Set the Type of a Property to ALL SubClasses of a Certain BaseType?

(I don't think so, but you never know....)

If not: is there a way to tell vs to show Only BaseType & DerivedTypes of a certain Object in the DropDownPortion of a Combo in the Property-Window.

This all is in vb.Net 2003

TIA,
Michael

Nov 20 '05 #1
5 1304
Hi Michael,

I wonder why you did not set the type of the property to Form directly,
because it seems that all the "Sibling Classes" you are using inherits from
Form.
Also can you post some code snippet to show us what you want to do?
I will appreciate your efforts.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #2
Hi Peter,

The Forms:

Namespace MyNamespace.Windows.Forms
Public Class FormA
Inherits System.Windows.Forms.Form
........

Namespace MyNamespace.Windows.Forms
Public Class FormB
Inherits System.Windows.Forms.Form
........

Namespace MyNamespace.Windows.Forms
Public Class FormC
Inherits System.Windows.Forms.Form
........

Namespace MyNamespace.Windows.Forms
Public Class FormB_A
Inherits MyNamespace.Windows.Forms.FormB
........

Namespace MyNamespace.Windows.Forms
Public Class FormB_B
Inherits MyNamespace.Windows.Forms.FormB
........

The Components (eg Typed DataSets):

Public Class tdsA
Inherits schemaA (Generated Schema by Visual Studio)
........
' OwnerForm
Dim _OwnerForm As MyNamespace.Windows.Forms.FormB
<EditorBrowsable(EditorBrowsableState.Always), _
Browsable(True), _
Category("Blabla"), _
Description("The container-form of the current DataSet-Instance.")> _
Public Property OwnerForm() As MyNamespace.Windows.Forms.FormB
Get
Return _OwnerForm
End Get
Set(ByVal Value As MyNamespace.Windows.Forms.FormB)
' Perform some checkings
............
_OwnerForm = Value
End Set
End Property
So in OwnerForm I want to be Able to stuff all current Forms (types), but more important: also future Forms (new derived types)
So basically: every form which is eventually derived from System.Windows.Forms.Form.

Regards,
Michael

Nov 20 '05 #3
Wow Peter,

I just tried this ("one never knows") and it works:

Public Property OwnerForm() As Form

How is this possible?
Will this property accept all form-derived types?

I just assumed that defining the type as System.Windows.Forms.Form would't
allow Subclasses of that class.

Thanks,

Michael

""Peter Huang"" <v-******@online.microsoft.com> wrote in message
news:Pr**************@cpmsftngxa10.phx.gbl...
Hi Michael,

I wonder why you did not set the type of the property to Form directly,
because it seems that all the "Sibling Classes" you are using inherits from Form.
Also can you post some code snippet to show us what you want to do?
I will appreciate your efforts.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #4
Hi Michael,

In .NET framework all type inherits from Object, so every type is kind of
object.
Analogously, since all the sub class you are using inherits from Form, so
they are a kind of Form(BaseClass).
e.g.
Object---->Shape---->Rectange---->square
The square should be a kind of Shape.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #5
Thanks for this (obvious) clarification.
I have been Coding vb for nearly three years now, and have always
thought/assumed that the type "narrowed down" along with it's subclasses. I
you think how many times I've used "Object" as a placeholder.... it's
correct to tell I've been "blind" (and stupid) all those years.

Thanks alot Peter,

Michael
Nov 20 '05 #6

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

Similar topics

3
by: Peter Rohleder | last post by:
Hi, I'm using a style-sheet where I make use of the XPATH-"following-sibling"-expression. The part which makes problems looks similar to the following code: --------------------------- ...
1
by: Philipp Lenssen | last post by:
I have some chapters a document goes through, so at the end of each document I want to output "Continue with XYZ", where XYZ is the next-sibling of the current one I select. However I don't know...
1
by: Niall Smart | last post by:
Hi I'm trying to emulate a "following-sibling-or-self" XPath axis without using the union operator. The XML looks like this: <deeply-nested> <select> <option value="1">One</option> <option...
3
by: Phoenix | last post by:
I am trying to print date headings over comments (as headings) I have a simple XML file : <comments> <comment id=1234 yyyymmdd="20041230" flag="Y">..text..</comment> <comment id=1309...
2
by: Michael K?nig | last post by:
Hello, I've an XML-file structured like this <table> <tr> <td>Nombre:</td> <td>Joseph</td> <td>Apellido:</td> <td>Ratzinger</td>
0
by: Elaine | last post by:
I have a truly curious problem with HtmlHelp and Sibling Mode in Visual C++ ..Net 2003 in an MFC app. Sibling mode allows the help viewer to display on top of the app, but if the app is clicked,...
11
by: localpricemaps | last post by:
i have some html which looks like this where i want to scrape out the href stuff (the www.cnn.com part) <div class="noFood">Cheese</div> <div class="food">Blue</div> <a class="btn" href =...
3
by: patrizio.trinchini | last post by:
Hi, how can remove sibling elements based on the value of an attribute ? For instance, gven the XML document: <root> <parentElment> <testElement name="A"> <removableElement/>
12
by: apicard | last post by:
I have a simple document like this: <Accept> <XXXX/> <Token image="From"/> <Date value="2007-01-01"/> <Token image="To"/> <Date value="2007-01-01"/> </Accept>
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: 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$) { } ...
0
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...
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
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...

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.