all groups > dotnet drawing api > april 2004 >
You're in the

dotnet drawing api

group:

Overriding "CanParent" - Does not Works


Overriding "CanParent" - Does not Works Nilesh Rade
4/27/2004 4:21:02 AM
dotnet drawing api: Hi
I am having a custom Tab control. In the Control's designer class am adding the follwoing code but it is not working i am still able to drag and drop a button or other controls on tabControl. But it works if I drag and drop a control, say button on from, and hten cut and try to paste it on my Tab Control.
I am wondering why it doesn't work if i directly try to add a control from tool box??Ideally it should throw me an error.....
Anyone has faced this probelm.....

public class CustomTabControlDesigner : System.Windows.Forms.Design.ParentControlDesigne


public override bool CanParent(Control control)

{
return (control is CustomTabPage);
}



Re: Overriding "CanParent" - Does not Works Jacob Grass [MVP]
4/27/2004 8:17:13 AM
[quoted text, click to view]


I have encountered this same problem and have not been able to get it
working correctly...


--
Jacob Grass
Microsoft .NET MVP
Check out http://windowsforms.net

Re: Overriding "CanParent" - Does not Works Andrew S (Infragistics)
5/2/2004 8:49:32 PM
One way would be to override the OnDragOver of the controldesigner and set
the effect of the event args to none. Another way would be to override the
createcontrolsinstance property of the control and provide your own derived
controlcollection where you validate what types of controls can be added in
the add/addrange/etc.

[quoted text, click to view]

Re: Overriding "CanParent" - Does not Works Nilesh Rade
5/4/2004 1:50:08 AM

Hi Andrew,
I tried OnDragOver but it will not be a soluiton because i can still add
the control noy by dragging but by just selecting it from the tool box
and drawing it on the control.
Again the control which am trying to drag is still there in the memory
and can be seen in the mouse curson which shows it.........

Do you have any other alternative????

--Nilesh



*** Sent via Developersdex http://www.developersdex.com ***
AddThis Social Bookmark Button