Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / March 2005

Tip: Looking for answers? Try searching our database.

Only allowing certain types of controls to be dropped on a parent control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Robin Sanner - 25 Feb 2005 20:39 GMT
I have a parent control with the following designer:

Public Class MyParentControlDesigner
   Inherits ParentControlDesigner
...
Public Overloads Overrides Function CanParent(ByVal control As Control) As
Boolean
   Return TypeOf control Is MyChildControl
End Function

Public Overloads Overrides Function CanParent(ByVal controlDesigner As
ControlDesigner) As Boolean)
   Return TypeOf controlDesigner Is MyChildControlDesigner
End Function
End Class

I only want to allow typeof of MyChildControl to be dropped on this surface.
Unfortunately these methods are never actually called and I can drop any
type of control into MyParentControl.  I verified this by putting a
System.Diagnostics.Debugger.Break before the Return statements in the
functions.

Why aren't these methods being called? Is this the correct way to do this?

Thank you
Robin Sanner
robin.sanner@verizon.net
joeycalisay - 28 Feb 2005 08:28 GMT
Assuming that <VB>TypeOf control Is MyChildControl<VB> is the VB equivalent
of <C#>control is MyChildControl <C#>, which I believe are equivalent from a
previous encounter in a form, it should work.  Perhaps this is related to
your post where the custom designer is not being utilized by your custom
control (Initialize method not being hit)

Signature

Joey Calisay
http://spaces.msn.com/members/joeycalisay/

> I have a parent control with the following designer:
>
[quoted text clipped - 23 lines]
> Robin Sanner
> robin.sanner@verizon.net
Robin Sanner - 01 Mar 2005 14:12 GMT
No this issue doesn't have anything to do with other messages I have posted.
In this case the Designer is in fact being loaded but these methods are
never called.

> Assuming that <VB>TypeOf control Is MyChildControl<VB> is the VB
> equivalent
[quoted text clipped - 34 lines]
>> Robin Sanner
>> robin.sanner@verizon.net
jer_m - 01 Mar 2005 17:52 GMT
Hi Robin,

Are you dropping these controls from the toolbox?

If so... as Joey points out in the following post

ParentControlDesigner CanParent

http://groups-beta.google.com/group/microsoft.public.dotnet.framework.windowsfor
ms.designtime/browse_frm/thread/d0e87992a884d901/99443a5e13c9af5f?q=&_done=%2Fgr
oups%3Fenc_author%3Df_LP2w8AAAA0lAoO3iVRRlTqB6TidsrC%26&_doneTitle=Back+to+Searc
h&&d#99443a5e13c9af5f


"The CanParent method is only executed if the control dragged into the
container control is from the form and not from toolbox"

To prevent a control from being added from the toolbox look at Shawn's
post

Preventing controls from being added to container

http://groups-beta.google.com/group/microsoft.public.dotnet.framework.windowsfor
ms/browse_frm/thread/c1fcb1ea56d0e2a5/5ce3b9b82fd8ed29?q=%22Preventing+controls+
from+being+added+to+container%22&_done=%2Fgroups%3Fq%3D%22Preventing+controls+fr
om+being+added+to+container%22%26qt_s%3DSearch+Groups%26&_doneTitle=Back+to+Sear
ch&&d#5ce3b9b82fd8ed29


Kind Regards,
Jerron

> No this issue doesn't have anything to do with other messages I have posted.
> In this case the Designer is in fact being loaded but these methods are
[quoted text clipped - 24 lines]
> >>
> >> Public Overloads Overrides Function CanParent(ByVal
controlDesigner As
> >> ControlDesigner) As Boolean)
> >>     Return TypeOf controlDesigner Is MyChildControlDesigner
[quoted text clipped - 14 lines]
> >> Robin Sanner
> >> robin.sanner@verizon.net
joeycalisay - 02 Mar 2005 01:15 GMT
My point is: Are you sure that your custom designer is being used by your
custom control?  If you are having some problems where the Designer is not
Initialized for its specific component (Initialize method not being hit at
debug), then I doubt that your designer class is being used by the
component.

Signature

Joey Calisay
http://spaces.msn.com/members/joeycalisay/

> No this issue doesn't have anything to do with other messages I have posted.
> In this case the Designer is in fact being loaded but these methods are
[quoted text clipped - 38 lines]
> >> Robin Sanner
> >> robin.sanner@verizon.net

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.