Hi Kris,
Thank you for your response.
My answers to your two questions are listed below.
1. About DocumentDesigner
I performed a test on the DocumentDesigner. I set up a Windows project, in
which I derive a class called MyDesigner from DocumentDesigner class.
Below is the code of the MyDesigner class.
using System.Windows.Forms.Design;
using System.ComponentModel.Design;
using System.Windows.Forms;
public class MyDesigner : DocumentDesigner
{
public override DesignerVerbCollection Verbs
{
get
{
// add a verb to the designer to distinguish between the
default form designer
DesignerVerbCollection c = base.Verbs;
c.Add(new DesignerVerb("MYVERB", new EventHandler(EH)));
return c;
}
}
private void EH(object sender, EventArgs e)
{
MessageBox.Show("MY VERB!");
}
}
Then I add a UserControl named UserControl1 in the project and add
DesignerAttribute[typeof(MyDesigner),typeof(IRootDesigner)] to the
UserControl1 class. The statements are shown below.
using System.ComponentModel.Design;
[Designer(typeof(MyDesigner), typeof(IRootDesigner))]
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
}
When I open the UserControl1 in designer and right click on it, the verb
"MYVERB" won't appear in the context menu. This is because the UserControl1
is displayed by VS with the default designer. The new designer--MyDesigner
only takes effect on the class derived from the UserControl1.
I didn't see the problem that " there is always a border of control and
small padding on the top and left ". Would you tell me what you mean by
that?
2. About ScrollableControlDesigner
ScrollableControlDesiger should be only used with srcollable control, such
as Panel. But it doesn't provide a root-level design mode view. So
ScrollableControlDesigner couldn't be associated with a form or user
control.
I have performed a test but I didn't reproduce the problem you described.
Below is the steps of my test.
a. Inherite a new class from ScrollableDesigner. The code of the new class
is like below.
using System.Windows.Forms.Design;
using System.ComponentModel.Design;
using System.Windows.Forms;
class MyScollableControlDesigner:ScrollableControlDesigner
{
public override DesignerVerbCollection Verbs
{
get
{
DesignerVerbCollection c = base.Verbs;
c.Add(new DesignerVerb("MYVERB", new EventHandler(EH)));
return c;
}
}
private void EH(object sender, EventArgs e)
{
MessageBox.Show("MY VERB in scrollable component!");
}
}
b. Inherite a new class named MyPanel from Panel and associate the new
designer with MyPanel.The code of the new class is like below.
using System.Windows.Forms;
using System.ComponentModel;
[DesignerAttribute(typeof(MyScollableControlDesigner))]
public class MyPanel:Panel
{ }
c. Build the project and drag&drop a MyPanel from toolbox onto a form.
d. Drag&drop a common control onto the MyPanel on the form in the designer.
Hope this helps.
If you have anything unclear or any questions, please feel free to let me
know.
Sincerely,
Linda Liu
Microsoft Online Community Support
campa - 20 Oct 2008 08:39 GMT
Hi, i was looking for something like that, i got the same problem.
I think its a standard attitude of windows controls, i don't know why and i
find no way to manage that.
You can see an example on
http://windowsclient.net/articles/shapedesigner.aspx
In the shape at step 3. The TestForm isnt at location 0, 0 theres a padding
and i'm not able to remove it.
If you built a custom user control as a designer and you override
OnLocationChanged you can see the control location and its something like 13,
13.
Also i would like to add vertical and horizontal rulers, but i can't find the
way out to do that.
Any hints?
Cya.
>Hi Kris,
>
>I didn't see the problem that " there is always a border of control and
>small padding on the top and left ". Would you tell me what you mean by
>that?
Hi Kris,
I am closely monitoring the newsgroup and I am contacting you to check the
issue status.
If the problem is not resolved or you have anything unclear, please feel
free to post in the newsgroup and we will follow up.
Thank you for using our MSDN Managed Newsgroup Support Service!
Sincerely,
Linda Liu
Microsoft Online Community Support